Rebased ref, commits from common ancestor: commit 05deeeeb85cc62025137b627e947e981417c9c36 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 12:49:12 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:35 2021 +0900
vcl: add TIF case to GraphicDescriptorTest Change-Id: I2e2724fda545e67777c1101b33cc10483f73b3a5 diff --git a/vcl/qa/cppunit/GraphicDescriptorTest.cxx b/vcl/qa/cppunit/GraphicDescriptorTest.cxx index 13f51262c233..65eca603da62 100644 --- a/vcl/qa/cppunit/GraphicDescriptorTest.cxx +++ b/vcl/qa/cppunit/GraphicDescriptorTest.cxx @@ -26,11 +26,13 @@ class GraphicDescriptorTest : public CppUnit::TestFixture void testDetectPNG(); void testDetectJPG(); void testDetectGIF(); + void testDetectTIF(); CPPUNIT_TEST_SUITE(GraphicDescriptorTest); CPPUNIT_TEST(testDetectPNG); CPPUNIT_TEST(testDetectJPG); CPPUNIT_TEST(testDetectGIF); + CPPUNIT_TEST(testDetectTIF); CPPUNIT_TEST_SUITE_END(); }; @@ -96,6 +98,20 @@ void GraphicDescriptorTest::testDetectGIF() CPPUNIT_ASSERT_EQUAL(tools::Long(100), aDescriptor.GetSizePixel().Height()); } +void GraphicDescriptorTest::testDetectTIF() +{ + SvMemoryStream aStream; + createBitmapAndExportForType(aStream, u"tif"); + + GraphicDescriptor aDescriptor(aStream, nullptr); + aDescriptor.Detect(true); + + CPPUNIT_ASSERT_EQUAL(GraphicFileFormat::TIF, aDescriptor.GetFileFormat()); + + CPPUNIT_ASSERT_EQUAL(tools::Long(100), aDescriptor.GetSizePixel().Width()); + CPPUNIT_ASSERT_EQUAL(tools::Long(100), aDescriptor.GetSizePixel().Height()); +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(GraphicDescriptorTest); commit 73a139a9896df7b8455f095b7c005d11f9cb7683 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 12:30:25 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:35 2021 +0900 Move GIF writer from filter module into VCL Change-Id: I8db3ca0f7953b44791bda47534220902931fab8d diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index 95c8184009d7..c72ccc9dd488 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -189,9 +189,6 @@ bool ConstParams::CheckTraverseFunctionDecl(FunctionDecl * functionDecl) || name.startswith("Read_F_") // UNO component entry points || name.endswith("component_getFactory") - || name == "egiGraphicExport" - || name == "etiGraphicExport" - || name == "epsGraphicExport" // callback for some external code? || name == "ScAddInAsyncCallBack" // used as function pointers diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk deleted file mode 100644 index b40da250a183..000000000000 --- a/filter/Library_gie.mk +++ /dev/null @@ -1,56 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -$(eval $(call gb_Library_Library,gie)) - -$(eval $(call gb_Library_set_include,gie,\ - $$(INCLUDE) \ - -I$(SRCDIR)/filter/inc \ -)) - -$(eval $(call gb_Library_use_external,gie,boost_headers)) - -$(eval $(call gb_Library_use_sdk_api,gie)) - -$(eval $(call gb_Library_use_custom_headers,gie,\ - officecfg/registry \ -)) - -$(eval $(call gb_Library_use_common_precompiled_header,gie)) - -$(eval $(call gb_Library_use_libraries,gie,\ - basegfx \ - comphelper \ - i18nlangtag \ - svt \ - vcl \ - utl \ - tl \ - tk \ - cppu \ - sal \ - salhelper \ -)) - -$(eval $(call gb_Library_add_exception_objects,gie,\ - filter/source/graphicfilter/egif/egif \ - filter/source/graphicfilter/egif/giflzwc \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index 2fb2e4c0c8e3..42a82bacf5c0 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -21,7 +21,6 @@ $(eval $(call gb_Module_Module,filter)) $(eval $(call gb_Module_add_targets,filter,\ Configuration_filter \ CustomTarget_svg \ - Library_gie \ Library_filterconfig \ Library_icg \ Library_msfilter \ diff --git a/filter/source/config/fragments/internalgraphicfilters/gif_Export.xcu b/filter/source/config/fragments/internalgraphicfilters/gif_Export.xcu index 7f021c1b9a7f..f55d1ba55385 100644 --- a/filter/source/config/fragments/internalgraphicfilters/gif_Export.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/gif_Export.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="gif_Export" oor:op="replace" > - <prop oor:name="Type"><value>gif_Graphics_Interchange</value></prop> - <prop oor:name="FormatName"><value>egi</value></prop> - <prop oor:name="RealFilterName"/> - <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> - <prop oor:name="UIName"> - <value xml:lang="en-US">GIF - Graphics Interchange Format</value> - </prop> - <prop oor:name="Flags"><value>EXPORT</value></prop> - </node> + +<node oor:name="gif_Export" oor:op="replace" > + <prop oor:name="Type"><value>gif_Graphics_Interchange</value></prop> + <prop oor:name="FormatName"><value>SVEGIF</value></prop> + <prop oor:name="RealFilterName"/> + <prop oor:name="UIComponent"><value>com.sun.star.svtools.SvFilterOptionsDialog</value></prop> + <prop oor:name="UIName"> + <value xml:lang="en-US">GIF - Graphics Interchange Format</value> + </prop> + <prop oor:name="Flags"><value>EXPORT</value></prop> +</node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index e1da325eab2a..88b5fea0481c 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -99,6 +99,7 @@ namespace o3tl #define EXP_PNG "SVEPNG" #define EXP_TIFF "SVTIFF" #define EXP_EPS "SVEEPS" +#define EXP_GIF "SVEGIF" #define BMP_SHORTNAME u"BMP" diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 81284432553b..7d3e1ec19a87 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3916,9 +3916,6 @@ filter/source/config/cache/typedetection.cxx filter/source/config/cache/typedetection.hxx filter/source/graphic/GraphicExportFilter.cxx filter/source/graphic/GraphicExportFilter.hxx -filter/source/graphicfilter/egif/egif.cxx -filter/source/graphicfilter/egif/giflzwc.cxx -filter/source/graphicfilter/egif/giflzwc.hxx filter/source/graphicfilter/icgm/actimpr.cxx filter/source/graphicfilter/icgm/bitmap.cxx filter/source/graphicfilter/icgm/bitmap.hxx @@ -14902,6 +14899,9 @@ vcl/source/filter/FilterConfigCache.hxx vcl/source/filter/FilterConfigItem.cxx vcl/source/filter/graphicfilter.cxx vcl/source/filter/graphicfilter2.cxx +vcl/source/filter/egif/egif.cxx +vcl/source/filter/egif/giflzwc.cxx +vcl/source/filter/egif/giflzwc.hxx vcl/source/filter/eps/eps.cxx vcl/source/filter/etiff/etiff.cxx vcl/source/filter/idxf/dxf2mtf.cxx diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index bea21fee0867..0c37cf54684b 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -427,6 +427,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/components/dtranscomp \ vcl/source/components/factory \ vcl/source/components/fontident \ + vcl/source/filter/egif/egif \ + vcl/source/filter/egif/giflzwc \ vcl/source/filter/eps/eps \ vcl/source/filter/etiff/etiff \ vcl/source/filter/FilterConfigCache \ diff --git a/vcl/inc/filter/GifWriter.hxx b/vcl/inc/filter/GifWriter.hxx new file mode 100644 index 000000000000..6512c4bf6f2f --- /dev/null +++ b/vcl/inc/filter/GifWriter.hxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/graph.hxx> +#include <vcl/FilterConfigItem.hxx> + +VCL_DLLPUBLIC bool ExportGifGraphic(SvStream& rStream, Graphic& rGraphic, + FilterConfigItem* pFilterConfigItem); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index d8ab4d44e0a8..411d44a5801d 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -41,10 +41,11 @@ using namespace ::com::sun::star::configuration ; const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameList[] = { - IMP_BMP, IMP_GIF, IMP_PNG, IMP_JPEG, IMP_XBM, IMP_XPM, - EXP_BMP, EXP_JPEG, EXP_PNG, IMP_MOV, IMP_TIFF, EXP_TIFF, - IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, IMP_PCX, IMP_PSD, - IMP_PCD, IMP_PBM, IMP_DXF, nullptr + IMP_BMP, IMP_GIF, IMP_PNG, IMP_JPEG, IMP_TIFF, + IMP_XBM, IMP_XPM, IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, + IMP_PCX, IMP_MOV, IMP_PSD, IMP_PCD, IMP_PBM, IMP_DXF, + EXP_BMP, EXP_GIF, EXP_PNG, EXP_JPEG, EXP_TIFF, + nullptr }; const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] = @@ -56,7 +57,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameL const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] = { - "egi", "epb", "epg", "epp", nullptr + nullptr }; void FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry ) @@ -225,7 +226,7 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] = "eps","1","SVIEPS", "eps","2","SVEEPS", "gif","1","SVIGIF", - "gif","2","egi", + "gif","2","SVEGIF", "jpg","1","SVIJPEG", "jpg","2","SVEJPEG", "mov","1","SVMOV", diff --git a/filter/source/graphicfilter/egif/egif.cxx b/vcl/source/filter/egif/egif.cxx similarity index 99% rename from filter/source/graphicfilter/egif/egif.cxx rename to vcl/source/filter/egif/egif.cxx index 7a70d337e6c5..bfd41d952b4c 100644 --- a/filter/source/graphicfilter/egif/egif.cxx +++ b/vcl/source/filter/egif/egif.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/task/XStatusIndicator.hpp> #include "giflzwc.hxx" #include <memory> +#include <filter/GifWriter.hxx> namespace { @@ -539,8 +540,7 @@ void GIFWriter::WriteTerminator() } -extern "C" SAL_DLLPUBLIC_EXPORT bool -egiGraphicExport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ) +bool ExportGifGraphic(SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem) { GIFWriter aWriter(rStream); return aWriter.WriteGIF(rGraphic, pConfigItem); diff --git a/filter/source/graphicfilter/egif/giflzwc.cxx b/vcl/source/filter/egif/giflzwc.cxx similarity index 100% rename from filter/source/graphicfilter/egif/giflzwc.cxx rename to vcl/source/filter/egif/giflzwc.cxx diff --git a/filter/source/graphicfilter/egif/giflzwc.hxx b/vcl/source/filter/egif/giflzwc.hxx similarity index 100% rename from filter/source/graphicfilter/egif/giflzwc.hxx rename to vcl/source/filter/egif/giflzwc.hxx diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 817900777ac6..43851e9a56b5 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -60,6 +60,7 @@ #include <filter/PcdReader.hxx> #include <filter/PbmReader.hxx> #include <filter/DxfReader.hxx> +#include <filter/GifWriter.hxx> #include <osl/module.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/Size.hpp> @@ -1984,12 +1985,6 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObje return nRetValue; } -#ifdef DISABLE_DYNLOADING - -extern "C" bool egiGraphicExport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); - -#endif - ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& rPath, SvStream& rOStm, sal_uInt16 nFormat, const css::uno::Sequence< css::beans::PropertyValue >* pFilterData ) { @@ -2017,7 +2012,6 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r FilterConfigItem aConfigItem( pFilterData ); OUString aFilterName( pConfig->GetExportFilterName( nFormat ) ); - OUString aExternalFilterName(pConfig->GetExternalFilterName(nFormat, true)); ErrCode nStatus = ERRCODE_NONE; GraphicType eType; Graphic aGraphic = ImpGetScaledGraphic( rGraphic, aConfigItem ); @@ -2079,7 +2073,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r if( rOStm.GetError() ) nStatus = ERRCODE_GRFILTER_IOERROR; } - if (aFilterName.equalsIgnoreAsciiCase(EXP_TIFF)) + else if (aFilterName.equalsIgnoreAsciiCase(EXP_TIFF)) { if (!ExportTiffGraphicImport(rOStm, aGraphic, &aConfigItem)) nStatus = ERRCODE_GRFILTER_FORMATERROR; @@ -2087,6 +2081,14 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r if( rOStm.GetError() ) nStatus = ERRCODE_GRFILTER_IOERROR; } + else if (aFilterName.equalsIgnoreAsciiCase(EXP_GIF)) + { + if (!ExportGifGraphic(rOStm, aGraphic, &aConfigItem)) + nStatus = ERRCODE_GRFILTER_FORMATERROR; + + if( rOStm.GetError() ) + nStatus = ERRCODE_GRFILTER_IOERROR; + } else if( aFilterName.equalsIgnoreAsciiCase( EXP_SVMETAFILE ) ) { sal_Int32 nVersion = aConfigItem.ReadInt32( "Version", 0 ) ; @@ -2312,35 +2314,6 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r else nStatus = ERRCODE_GRFILTER_FILTERERROR; } - else - { - sal_Int32 nIdx {aFilterPath.isEmpty() ? -1 : 0}; - while (nIdx>=0) - { -#ifndef DISABLE_DYNLOADING - OUString aPhysicalName( ImpCreateFullFilterPath( aFilterPath.getToken(0, ';', nIdx), aFilterName ) ); - osl::Module aLibrary( aPhysicalName ); - - PFilterCall pFunc = nullptr; - if (aExternalFilterName == "egi") - pFunc = reinterpret_cast<PFilterCall>(aLibrary.getFunctionSymbol("egiGraphicExport")); - // Execute dialog in DLL - #else - --nIdx; // Just one iteration - PFilterCall pFunc = NULL; - if (aExternalFilterName == "egi") - pFunc = egiGraphicExport; - #endif - if( pFunc ) - { - if ( !(*pFunc)( rOStm, aGraphic, &aConfigItem ) ) - nStatus = ERRCODE_GRFILTER_FORMATERROR; - break; - } - else - nStatus = ERRCODE_GRFILTER_FILTERERROR; - } - } } if( nStatus != ERRCODE_NONE ) { commit da76ea67ba53d5143978394aeedbb9390ea5de52 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 11:35:38 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:35 2021 +0900 Move DXF reader from filter module into VCL Change-Id: If1a933256401c1a971f581d1b389ca06fd77eaae diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fbbf450b6530..1dfddfaa6785 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -6275,9 +6275,6 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char InitVCL(); } - // pre-load all graphic libraries. - GraphicFilter::GetGraphicFilter().preload(); - // pre-load all component libraries. if (!xContext.is()) throw css::uno::DeploymentException("preInit: XComponentContext is not created"); diff --git a/filter/CppunitTest_filter_dxf_test.mk b/filter/CppunitTest_filter_dxf_test.mk deleted file mode 100644 index 4a10c1845cef..000000000000 --- a/filter/CppunitTest_filter_dxf_test.mk +++ /dev/null @@ -1,39 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_CppunitTest_CppunitTest,filter_dxf_test)) - -$(eval $(call gb_CppunitTest_use_external,filter_dxf_test,boost_headers)) - -$(eval $(call gb_CppunitTest_add_exception_objects,filter_dxf_test, \ - filter/qa/cppunit/filters-dxf-test \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,filter_dxf_test, \ - gie \ - sal \ - test \ - tl \ - unotest \ - vcl \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,filter_dxf_test)) - -$(eval $(call gb_CppunitTest_use_ure,filter_dxf_test)) -$(eval $(call gb_CppunitTest_use_vcl,filter_dxf_test)) - -$(eval $(call gb_CppunitTest_use_components,filter_dxf_test,\ - configmgr/source/configmgr \ - i18npool/util/i18npool \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,filter_dxf_test)) - -# vim: set noet sw=4 ts=4: diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk index e04eb08fda7f..b40da250a183 100644 --- a/filter/Library_gie.mk +++ b/filter/Library_gie.mk @@ -51,14 +51,6 @@ $(eval $(call gb_Library_use_libraries,gie,\ $(eval $(call gb_Library_add_exception_objects,gie,\ filter/source/graphicfilter/egif/egif \ filter/source/graphicfilter/egif/giflzwc \ - filter/source/graphicfilter/idxf/dxf2mtf \ - filter/source/graphicfilter/idxf/dxfblkrd \ - filter/source/graphicfilter/idxf/dxfentrd \ - filter/source/graphicfilter/idxf/dxfgrprd \ - filter/source/graphicfilter/idxf/dxfreprd \ - filter/source/graphicfilter/idxf/dxftblrd \ - filter/source/graphicfilter/idxf/dxfvec \ - filter/source/graphicfilter/idxf/idxf \ )) # vim: set noet sw=4 ts=4: diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index 607a5fc46d0c..2fb2e4c0c8e3 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -55,7 +55,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\ ifneq ($(DISABLE_CVE_TESTS),TRUE) $(eval $(call gb_Module_add_check_targets,filter,\ - CppunitTest_filter_dxf_test \ CppunitTest_filter_svg \ )) endif diff --git a/filter/source/config/fragments/internalgraphicfilters/dxf_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/dxf_Import.xcu index 1ab3279bd809..d4ce34e28b1e 100644 --- a/filter/source/config/fragments/internalgraphicfilters/dxf_Import.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/dxf_Import.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="dxf_Import" oor:op="replace" > - <prop oor:name="Type"><value>dxf_AutoCAD_Interchange</value></prop> - <prop oor:name="FormatName"><value>idx</value></prop> - <prop oor:name="RealFilterName"><value>DXF - AutoCAD Interchange</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">DXF - AutoCAD Interchange Format</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="dxf_Import" oor:op="replace" > + <prop oor:name="Type"><value>dxf_AutoCAD_Interchange</value></prop> + <prop oor:name="FormatName"><value>SVDXF</value></prop> + <prop oor:name="RealFilterName"><value>DXF - AutoCAD Interchange</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">DXF - AutoCAD Interchange Format</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 73b8e932fbd6..e1da325eab2a 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -87,6 +87,8 @@ namespace o3tl #define IMP_PSD "SVPSD" #define IMP_PCD "SVPCD" #define IMP_PBM "SVPBM" +#define IMP_DXF "SVDXF" + #define EXP_BMP "SVBMP" #define EXP_SVMETAFILE "SVMETAFILE" #define EXP_WMF "SVWMF" @@ -335,8 +337,6 @@ public: ErrCode compressAsPNG(const Graphic& rGraphic, SvStream& rOutputStream); - void preload(); - ErrCode readGIF(SvStream& rStream, Graphic& rGraphic, GfxLinkType& rLinkType); ErrCode readPNG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, std::unique_ptr<sal_uInt8[]> & rpGraphicContent, sal_Int32& rGraphicContentSize); @@ -364,6 +364,7 @@ public: ErrCode readPSD(SvStream & rStream, Graphic & rGraphic); ErrCode readPCD(SvStream & rStream, Graphic & rGraphic); ErrCode readPBM(SvStream & rStream, Graphic & rGraphic); + ErrCode readDXF(SvStream & rStream, Graphic & rGraphic); private: OUString aFilterPath; diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 4cd0fd50c95e..81284432553b 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3890,7 +3890,6 @@ external/unixODBC/inc/odbc/sqlext.h external/unixODBC/inc/odbc/sqltypes.h external/unixODBC/inc/odbc/sqlucode.h filter/inc/strings.hxx -filter/qa/cppunit/filters-dxf-test.cxx filter/qa/cppunit/msfilter-test.cxx filter/qa/cppunit/priority-test.cxx filter/qa/cppunit/xslt-test.cxx @@ -3941,21 +3940,6 @@ filter/source/graphicfilter/icgm/classx.cxx filter/source/graphicfilter/icgm/elements.cxx filter/source/graphicfilter/icgm/elements.hxx filter/source/graphicfilter/icgm/outact.hxx -filter/source/graphicfilter/idxf/dxf2mtf.cxx -filter/source/graphicfilter/idxf/dxf2mtf.hxx -filter/source/graphicfilter/idxf/dxfblkrd.cxx -filter/source/graphicfilter/idxf/dxfblkrd.hxx -filter/source/graphicfilter/idxf/dxfentrd.cxx -filter/source/graphicfilter/idxf/dxfentrd.hxx -filter/source/graphicfilter/idxf/dxfgrprd.cxx -filter/source/graphicfilter/idxf/dxfgrprd.hxx -filter/source/graphicfilter/idxf/dxfreprd.cxx -filter/source/graphicfilter/idxf/dxfreprd.hxx -filter/source/graphicfilter/idxf/dxftblrd.cxx -filter/source/graphicfilter/idxf/dxftblrd.hxx -filter/source/graphicfilter/idxf/dxfvec.cxx -filter/source/graphicfilter/idxf/dxfvec.hxx -filter/source/graphicfilter/idxf/idxf.cxx filter/source/msfilter/countryid.cxx filter/source/msfilter/dffpropset.cxx filter/source/msfilter/escherex.cxx @@ -14803,6 +14787,7 @@ vcl/qa/cppunit/dndtest.cxx vcl/qa/cppunit/errorhandler.cxx vcl/qa/cppunit/font.cxx vcl/qa/cppunit/fontmetric.cxx +vcl/qa/cppunit/graphicfilter/filters-dxf-test.cxx vcl/qa/cppunit/graphicfilter/filters-eps-test.cxx vcl/qa/cppunit/graphicfilter/filters-met-test.cxx vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx @@ -14919,6 +14904,21 @@ vcl/source/filter/graphicfilter.cxx vcl/source/filter/graphicfilter2.cxx vcl/source/filter/eps/eps.cxx vcl/source/filter/etiff/etiff.cxx +vcl/source/filter/idxf/dxf2mtf.cxx +vcl/source/filter/idxf/dxf2mtf.hxx +vcl/source/filter/idxf/dxfblkrd.cxx +vcl/source/filter/idxf/dxfblkrd.hxx +vcl/source/filter/idxf/dxfentrd.cxx +vcl/source/filter/idxf/dxfentrd.hxx +vcl/source/filter/idxf/dxfgrprd.cxx +vcl/source/filter/idxf/dxfgrprd.hxx +vcl/source/filter/idxf/dxfreprd.cxx +vcl/source/filter/idxf/dxfreprd.hxx +vcl/source/filter/idxf/dxftblrd.cxx +vcl/source/filter/idxf/dxftblrd.hxx +vcl/source/filter/idxf/dxfvec.cxx +vcl/source/filter/idxf/dxfvec.hxx +vcl/source/filter/idxf/idxf.cxx vcl/source/filter/ieps/ieps.cxx vcl/source/filter/igif/decode.cxx vcl/source/filter/igif/decode.hxx diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk index ccb427dddd6c..ab5108f51b1c 100644 --- a/vcl/CppunitTest_vcl_filters_test.mk +++ b/vcl/CppunitTest_vcl_filters_test.mk @@ -10,6 +10,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,vcl_filters_test)) $(eval $(call gb_CppunitTest_add_exception_objects,vcl_filters_test, \ + vcl/qa/cppunit/graphicfilter/filters-dxf-test \ vcl/qa/cppunit/graphicfilter/filters-eps-test \ vcl/qa/cppunit/graphicfilter/filters-met-test \ vcl/qa/cppunit/graphicfilter/filters-pcd-test \ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 581e50aec36f..bea21fee0867 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -436,6 +436,14 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/GraphicNativeTransform \ vcl/source/filter/GraphicNativeMetadata \ vcl/source/filter/GraphicFormatDetector \ + vcl/source/filter/idxf/dxf2mtf \ + vcl/source/filter/idxf/dxfblkrd \ + vcl/source/filter/idxf/dxfentrd \ + vcl/source/filter/idxf/dxfgrprd \ + vcl/source/filter/idxf/dxfreprd \ + vcl/source/filter/idxf/dxftblrd \ + vcl/source/filter/idxf/dxfvec \ + vcl/source/filter/idxf/idxf \ vcl/source/filter/ieps/ieps \ vcl/source/filter/igif/decode \ vcl/source/filter/igif/gifread \ diff --git a/vcl/inc/filter/DxfReader.hxx b/vcl/inc/filter/DxfReader.hxx new file mode 100644 index 000000000000..f1e89bf4b115 --- /dev/null +++ b/vcl/inc/filter/DxfReader.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/graph.hxx> + +VCL_DLLPUBLIC bool ImportDxfGraphic(SvStream& rStream, Graphic& rGraphic); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/qa/cppunit/data/dxf/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/dxf/fail/.gitignore similarity index 100% rename from filter/qa/cppunit/data/dxf/fail/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/dxf/fail/.gitignore diff --git a/filter/qa/cppunit/data/dxf/fail/CVE-2010-1681-1.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/fail/CVE-2010-1681-1.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/fail/CVE-2010-1681-1.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/fail/CVE-2010-1681-1.dxf diff --git a/filter/qa/cppunit/data/dxf/fail/hang-1.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/fail/hang-1.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/fail/hang-1.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/fail/hang-1.dxf diff --git a/filter/qa/cppunit/data/dxf/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/dxf/indeterminate/.gitignore similarity index 100% rename from filter/qa/cppunit/data/dxf/indeterminate/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/dxf/indeterminate/.gitignore diff --git a/filter/qa/cppunit/data/dxf/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/dxf/pass/.gitignore similarity index 100% rename from filter/qa/cppunit/data/dxf/pass/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/dxf/pass/.gitignore diff --git a/filter/qa/cppunit/data/dxf/pass/bigangle-1.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/pass/bigangle-1.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/pass/bigangle-1.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/pass/bigangle-1.dxf diff --git a/filter/qa/cppunit/data/dxf/pass/loop-1.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/pass/loop-1.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/pass/loop-1.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/pass/loop-1.dxf diff --git a/filter/qa/cppunit/data/dxf/pass/loop-2.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/pass/loop-2.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/pass/loop-2.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/pass/loop-2.dxf diff --git a/filter/qa/cppunit/data/dxf/pass/pyramid.dxf b/vcl/qa/cppunit/graphicfilter/data/dxf/pass/pyramid.dxf similarity index 100% rename from filter/qa/cppunit/data/dxf/pass/pyramid.dxf rename to vcl/qa/cppunit/graphicfilter/data/dxf/pass/pyramid.dxf diff --git a/filter/qa/cppunit/filters-dxf-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-dxf-test.cxx similarity index 80% rename from filter/qa/cppunit/filters-dxf-test.cxx rename to vcl/qa/cppunit/graphicfilter/filters-dxf-test.cxx index 2dddac45d026..7a133500826a 100644 --- a/filter/qa/cppunit/filters-dxf-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-dxf-test.cxx @@ -12,15 +12,9 @@ #include <vcl/FilterConfigItem.hxx> #include <tools/stream.hxx> #include <vcl/graph.hxx> +#include <filter/DxfReader.hxx> -extern "C" -{ - SAL_DLLPUBLIC_EXPORT bool SAL_CALL - idxGraphicImport(SvStream & rStream, Graphic & rGraphic, - FilterConfigItem*); -} - -using namespace ::com::sun::star; +using namespace css; /* Implementation of Filters test */ @@ -51,17 +45,17 @@ bool DxfFilterTest::load(const OUString &, { SvFileStream aFileStream(rURL, StreamMode::READ); Graphic aGraphic; - return idxGraphicImport(aFileStream, aGraphic, nullptr); + return ImportDxfGraphic(aFileStream, aGraphic); } void DxfFilterTest::testCVEs() { +#ifndef DISABLE_CVE_TESTS testDir(OUString(), - m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/dxf/")); + m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/dxf/")); +#endif } CPPUNIT_TEST_SUITE_REGISTRATION(DxfFilterTest); -CPPUNIT_PLUGIN_IMPLEMENT(); - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 0f19f717f2c8..d8ab4d44e0a8 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -44,7 +44,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameLi IMP_BMP, IMP_GIF, IMP_PNG, IMP_JPEG, IMP_XBM, IMP_XPM, EXP_BMP, EXP_JPEG, EXP_PNG, IMP_MOV, IMP_TIFF, EXP_TIFF, IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, IMP_PCX, IMP_PSD, - IMP_PCD, IMP_PBM, nullptr + IMP_PCD, IMP_PBM, IMP_DXF, nullptr }; const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] = @@ -221,7 +221,7 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] = { "bmp","1","SVBMP", "bmp","2","SVBMP", - "dxf","1","idx", + "dxf","1","SVDXF", "eps","1","SVIEPS", "eps","2","SVEEPS", "gif","1","SVIGIF", diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index f76ede5dc840..817900777ac6 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -59,6 +59,7 @@ #include <filter/PsdReader.hxx> #include <filter/PcdReader.hxx> #include <filter/PbmReader.hxx> +#include <filter/DxfReader.hxx> #include <osl/module.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/Size.hpp> @@ -647,26 +648,9 @@ ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const OUString& rPathname, const #endif } -#ifdef DISABLE_DYNLOADING - -extern "C" bool idxGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); - -#endif - PFilterCall ImpFilterLibCacheEntry::GetImportFunction() { - if( !mpfnImport ) - { -#ifndef DISABLE_DYNLOADING - if (maFormatName == "idx") - mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("idxGraphicImport")); - #else - if (maFormatName == "idx") - mpfnImport = idxGraphicImport; - #endif - } - - return mpfnImport; + return nullptr; } namespace { @@ -1392,30 +1376,6 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size return aGraphic; } -void GraphicFilter::preload() -{ - sal_Int32 nTokenCount = comphelper::string::getTokenCount(aFilterPath, ';'); - ImpFilterLibCache& rCache = Cache::get(); - static const std::initializer_list<std::u16string_view> aFilterNames = { - u"idx", u"ipb", u"ipd" - }; - - // Load library for each filter. - for (const auto& rFilterName : aFilterNames) - { - ImpFilterLibCacheEntry* pFilter = nullptr; - // Look at the library in each element inside the filter path. - for (sal_Int32 i = 0; i < nTokenCount; ++i) - { - pFilter = rCache.GetFilter(aFilterPath.getToken(i, ';'), SVLIBRARY("gie"), OUString(rFilterName)); - if (pFilter) - { - break; - } - } - } -} - ErrCode GraphicFilter::readGIF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType) { if (ImportGIF(rStream, rGraphic)) @@ -1766,6 +1726,14 @@ ErrCode GraphicFilter::readPBM(SvStream & rStream, Graphic & rGraphic) return ERRCODE_GRFILTER_FILTERERROR; } +ErrCode GraphicFilter::readDXF(SvStream & rStream, Graphic & rGraphic) +{ + if (ImportDxfGraphic(rStream, rGraphic)) + return ERRCODE_NONE; + else + return ERRCODE_GRFILTER_FILTERERROR; +} + ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, SvStream& rIStream, sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags, const css::uno::Sequence< css::beans::PropertyValue >* /*pFilterData*/, @@ -1915,6 +1883,10 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, { nStatus = readPBM(rIStream, rGraphic); } + else if (aFilterName.equalsIgnoreAsciiCase(IMP_DXF)) + { + nStatus = readDXF(rIStream, rGraphic); + } else nStatus = ERRCODE_GRFILTER_FILTERERROR; } diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/vcl/source/filter/idxf/dxf2mtf.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxf2mtf.cxx rename to vcl/source/filter/idxf/dxf2mtf.cxx diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.hxx b/vcl/source/filter/idxf/dxf2mtf.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxf2mtf.hxx rename to vcl/source/filter/idxf/dxf2mtf.hxx diff --git a/filter/source/graphicfilter/idxf/dxfblkrd.cxx b/vcl/source/filter/idxf/dxfblkrd.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfblkrd.cxx rename to vcl/source/filter/idxf/dxfblkrd.cxx diff --git a/filter/source/graphicfilter/idxf/dxfblkrd.hxx b/vcl/source/filter/idxf/dxfblkrd.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfblkrd.hxx rename to vcl/source/filter/idxf/dxfblkrd.hxx diff --git a/filter/source/graphicfilter/idxf/dxfentrd.cxx b/vcl/source/filter/idxf/dxfentrd.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfentrd.cxx rename to vcl/source/filter/idxf/dxfentrd.cxx diff --git a/filter/source/graphicfilter/idxf/dxfentrd.hxx b/vcl/source/filter/idxf/dxfentrd.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfentrd.hxx rename to vcl/source/filter/idxf/dxfentrd.hxx diff --git a/filter/source/graphicfilter/idxf/dxfgrprd.cxx b/vcl/source/filter/idxf/dxfgrprd.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfgrprd.cxx rename to vcl/source/filter/idxf/dxfgrprd.cxx diff --git a/filter/source/graphicfilter/idxf/dxfgrprd.hxx b/vcl/source/filter/idxf/dxfgrprd.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfgrprd.hxx rename to vcl/source/filter/idxf/dxfgrprd.hxx diff --git a/filter/source/graphicfilter/idxf/dxfreprd.cxx b/vcl/source/filter/idxf/dxfreprd.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfreprd.cxx rename to vcl/source/filter/idxf/dxfreprd.cxx diff --git a/filter/source/graphicfilter/idxf/dxfreprd.hxx b/vcl/source/filter/idxf/dxfreprd.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfreprd.hxx rename to vcl/source/filter/idxf/dxfreprd.hxx diff --git a/filter/source/graphicfilter/idxf/dxftblrd.cxx b/vcl/source/filter/idxf/dxftblrd.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxftblrd.cxx rename to vcl/source/filter/idxf/dxftblrd.cxx diff --git a/filter/source/graphicfilter/idxf/dxftblrd.hxx b/vcl/source/filter/idxf/dxftblrd.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxftblrd.hxx rename to vcl/source/filter/idxf/dxftblrd.hxx diff --git a/filter/source/graphicfilter/idxf/dxfvec.cxx b/vcl/source/filter/idxf/dxfvec.cxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfvec.cxx rename to vcl/source/filter/idxf/dxfvec.cxx diff --git a/filter/source/graphicfilter/idxf/dxfvec.hxx b/vcl/source/filter/idxf/dxfvec.hxx similarity index 100% rename from filter/source/graphicfilter/idxf/dxfvec.hxx rename to vcl/source/filter/idxf/dxfvec.hxx diff --git a/filter/source/graphicfilter/idxf/idxf.cxx b/vcl/source/filter/idxf/idxf.cxx similarity index 90% rename from filter/source/graphicfilter/idxf/idxf.cxx rename to vcl/source/filter/idxf/idxf.cxx index ad75d6b5e1c3..26d42b10cbe4 100644 --- a/filter/source/graphicfilter/idxf/idxf.cxx +++ b/vcl/source/filter/idxf/idxf.cxx @@ -18,16 +18,14 @@ */ +#include <filter/DxfReader.hxx> #include <vcl/gdimtf.hxx> #include <vcl/graph.hxx> #include "dxf2mtf.hxx" -class FilterConfigItem; - //================== GraphicImport - the exported function ================ -extern "C" SAL_DLLPUBLIC_EXPORT bool -idxGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) +bool ImportDxfGraphic(SvStream & rStream, Graphic & rGraphic) { DXFRepresentation aDXF; DXF2GDIMetaFile aConverter; diff --git a/vcl/workben/dxffuzzer.cxx b/vcl/workben/dxffuzzer.cxx index 6ca526a1d8cf..8768072c93fb 100644 --- a/vcl/workben/dxffuzzer.cxx +++ b/vcl/workben/dxffuzzer.cxx @@ -10,6 +10,7 @@ #include <tools/stream.hxx> #include <vcl/FilterConfigItem.hxx> #include "commonfuzzer.hxx" +#include <filter/DxfReader.hxx> #include <config_features.h> #include <osl/detail/component-mapping.h> @@ -48,8 +49,6 @@ extern "C" void* lo_get_custom_widget_func(const char*) return nullptr; } -extern "C" bool idxGraphicImport(SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem); - extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { TypicalFuzzerInitialize(argc, argv); @@ -60,7 +59,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ); Graphic aGraphic; - (void)idxGraphicImport(aStream, aGraphic, nullptr); + (void)ImportDxfGraphic(aStream, aGraphic); return 0; } diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index 45deeee37169..5dafd12be683 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -52,6 +52,7 @@ #include <filter/PsdReader.hxx> #include <filter/PcdReader.hxx> #include <filter/PbmReader.hxx> +#include <filter/DxfReader.hxx> #include <osl/file.hxx> #include <osl/module.hxx> #include <tools/stream.hxx> @@ -165,7 +166,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) SvFileStream aFileStream(out, StreamMode::READ); ReadGDIMetaFile(aFileStream, aGDIMetaFile); } -#ifndef DISABLE_DYNLOADING else if (strcmp(argv[2], "pcd") == 0) { Graphic aGraphic; @@ -174,18 +174,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } else if (strcmp(argv[2], "dxf") == 0) { - static PFilterCall pfnImport(nullptr); - if (!pfnImport) - { - osl::Module aLibrary; - aLibrary.loadRelative(&thisModule, "libgielo.so"); - pfnImport = reinterpret_cast<PFilterCall>( - aLibrary.getFunctionSymbol("idxGraphicImport")); - aLibrary.release(); - } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); + ret = static_cast<int>(ImportDxfGraphic(aFileStream, aGraphic)); } else if (strcmp(argv[2], "met") == 0) { @@ -241,6 +232,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) SvFileStream aFileStream(out, StreamMode::READ); ret = static_cast<int>(ImportTiffGraphicImport(aFileStream, aGraphic)); } +#ifndef DISABLE_DYNLOADING else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0)) { static FFilterCall pfnImport(nullptr); commit 42778e2233cfef2d5c103e1c385d940338531092 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 10:47:14 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:34 2021 +0900 Move PBM,PPM reader from filter module into VCL Change-Id: I1ce998575f8d204045fabea184e80e71308a16b8 diff --git a/filter/CppunitTest_filter_ppm_test.mk b/filter/CppunitTest_filter_ppm_test.mk deleted file mode 100644 index 273db952300d..000000000000 --- a/filter/CppunitTest_filter_ppm_test.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_CppunitTest_CppunitTest,filter_ppm_test)) - -$(eval $(call gb_CppunitTest_use_external,filter_ppm_test,boost_headers)) - -$(eval $(call gb_CppunitTest_add_exception_objects,filter_ppm_test, \ - filter/qa/cppunit/filters-ppm-test \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,filter_ppm_test, \ - gie \ - sal \ - test \ - tl \ - unotest \ - vcl \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,filter_ppm_test)) - -$(eval $(call gb_CppunitTest_use_ure,filter_ppm_test)) -$(eval $(call gb_CppunitTest_use_vcl,filter_ppm_test)) - -$(eval $(call gb_CppunitTest_use_components,filter_ppm_test,\ - configmgr/source/configmgr \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,filter_ppm_test)) - -# vim: set noet sw=4 ts=4: diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk index d5ab8b8169a5..e04eb08fda7f 100644 --- a/filter/Library_gie.mk +++ b/filter/Library_gie.mk @@ -51,7 +51,6 @@ $(eval $(call gb_Library_use_libraries,gie,\ $(eval $(call gb_Library_add_exception_objects,gie,\ filter/source/graphicfilter/egif/egif \ filter/source/graphicfilter/egif/giflzwc \ - filter/source/graphicfilter/ipbm/ipbm \ filter/source/graphicfilter/idxf/dxf2mtf \ filter/source/graphicfilter/idxf/dxfblkrd \ filter/source/graphicfilter/idxf/dxfentrd \ diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index 678c882dce88..607a5fc46d0c 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -56,7 +56,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\ ifneq ($(DISABLE_CVE_TESTS),TRUE) $(eval $(call gb_Module_add_check_targets,filter,\ CppunitTest_filter_dxf_test \ - CppunitTest_filter_ppm_test \ CppunitTest_filter_svg \ )) endif diff --git a/filter/source/config/fragments/internalgraphicfilters/pbm_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/pbm_Import.xcu index 49db4b3c7eb4..0e7f0b9402b5 100644 --- a/filter/source/config/fragments/internalgraphicfilters/pbm_Import.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/pbm_Import.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="pbm_Import" oor:op="replace" > - <prop oor:name="Type"><value>pbm_Portable_Bitmap</value></prop> - <prop oor:name="FormatName"><value>ipb</value></prop> - <prop oor:name="RealFilterName"><value>PBM - Portable Bitmap</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PBM - Portable Bitmap</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="pbm_Import" oor:op="replace" > + <prop oor:name="Type"><value>pbm_Portable_Bitmap</value></prop> + <prop oor:name="FormatName"><value>SVPBM</value></prop> + <prop oor:name="RealFilterName"><value>PBM - Portable Bitmap</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PBM - Portable Bitmap</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/filter/source/config/fragments/internalgraphicfilters/pgm_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/pgm_Import.xcu index 2e1d4bb27f68..0356e69543f5 100644 --- a/filter/source/config/fragments/internalgraphicfilters/pgm_Import.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/pgm_Import.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="pgm_Import" oor:op="replace" > - <prop oor:name="Type"><value>pgm_Portable_Graymap</value></prop> - <prop oor:name="FormatName"><value>ipb</value></prop> - <prop oor:name="RealFilterName"><value>PGM - Portable Graymap</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PGM - Portable Graymap</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="pgm_Import" oor:op="replace" > + <prop oor:name="Type"><value>pgm_Portable_Graymap</value></prop> + <prop oor:name="FormatName"><value>SVPBM</value></prop> + <prop oor:name="RealFilterName"><value>PGM - Portable Graymap</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PGM - Portable Graymap</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/filter/source/config/fragments/internalgraphicfilters/ppm_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/ppm_Import.xcu index c2213e24f8bc..03134558c806 100644 --- a/filter/source/config/fragments/internalgraphicfilters/ppm_Import.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/ppm_Import.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="ppm_Import" oor:op="replace" > - <prop oor:name="Type"><value>ppm_Portable_Pixelmap</value></prop> - <prop oor:name="FormatName"><value>ipb</value></prop> - <prop oor:name="RealFilterName"><value>PPM - Portable Pixelmap</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PPM - Portable Pixelmap</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="ppm_Import" oor:op="replace" > + <prop oor:name="Type"><value>ppm_Portable_Pixelmap</value></prop> + <prop oor:name="FormatName"><value>SVPBM</value></prop> + <prop oor:name="RealFilterName"><value>PPM - Portable Pixelmap</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PPM - Portable Pixelmap</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 478e1c00a47a..73b8e932fbd6 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -86,6 +86,7 @@ namespace o3tl #define IMP_EPS "SVIEPS" #define IMP_PSD "SVPSD" #define IMP_PCD "SVPCD" +#define IMP_PBM "SVPBM" #define EXP_BMP "SVBMP" #define EXP_SVMETAFILE "SVMETAFILE" #define EXP_WMF "SVWMF" @@ -362,6 +363,7 @@ public: ErrCode readEPS(SvStream & rStream, Graphic & rGraphic); ErrCode readPSD(SvStream & rStream, Graphic & rGraphic); ErrCode readPCD(SvStream & rStream, Graphic & rGraphic); + ErrCode readPBM(SvStream & rStream, Graphic & rGraphic); private: OUString aFilterPath; diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index b7118132d5c2..4cd0fd50c95e 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3891,7 +3891,6 @@ external/unixODBC/inc/odbc/sqltypes.h external/unixODBC/inc/odbc/sqlucode.h filter/inc/strings.hxx filter/qa/cppunit/filters-dxf-test.cxx -filter/qa/cppunit/filters-ppm-test.cxx filter/qa/cppunit/msfilter-test.cxx filter/qa/cppunit/priority-test.cxx filter/qa/cppunit/xslt-test.cxx @@ -3957,7 +3956,6 @@ filter/source/graphicfilter/idxf/dxftblrd.hxx filter/source/graphicfilter/idxf/dxfvec.cxx filter/source/graphicfilter/idxf/dxfvec.hxx filter/source/graphicfilter/idxf/idxf.cxx -filter/source/graphicfilter/ipbm/ipbm.cxx filter/source/msfilter/countryid.cxx filter/source/msfilter/dffpropset.cxx filter/source/msfilter/escherex.cxx @@ -14810,6 +14808,7 @@ vcl/qa/cppunit/graphicfilter/filters-met-test.cxx vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx vcl/qa/cppunit/graphicfilter/filters-pcx-test.cxx vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx +vcl/qa/cppunit/graphicfilter/filters-ppm-test.cxx vcl/qa/cppunit/graphicfilter/filters-psd-test.cxx vcl/qa/cppunit/graphicfilter/filters-ras-test.cxx vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -14925,6 +14924,7 @@ vcl/source/filter/igif/decode.cxx vcl/source/filter/igif/decode.hxx vcl/source/filter/igif/gifread.cxx vcl/source/filter/imet/ios2met.cxx +vcl/source/filter/ipbm/ipbm.cxx vcl/source/filter/ipcd/ipcd.cxx vcl/source/filter/ipcx/ipcx.cxx vcl/source/filter/ipict/ipict.cxx diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk index 8ebc4c7c1ae0..ccb427dddd6c 100644 --- a/vcl/CppunitTest_vcl_filters_test.mk +++ b/vcl/CppunitTest_vcl_filters_test.mk @@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_filters_test, \ vcl/qa/cppunit/graphicfilter/filters-pcd-test \ vcl/qa/cppunit/graphicfilter/filters-pcx-test \ vcl/qa/cppunit/graphicfilter/filters-pict-test \ + vcl/qa/cppunit/graphicfilter/filters-ppm-test \ vcl/qa/cppunit/graphicfilter/filters-psd-test \ vcl/qa/cppunit/graphicfilter/filters-ras-test \ vcl/qa/cppunit/graphicfilter/filters-test \ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 34b7f0697436..581e50aec36f 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -440,6 +440,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/igif/decode \ vcl/source/filter/igif/gifread \ vcl/source/filter/imet/ios2met \ + vcl/source/filter/ipbm/ipbm \ vcl/source/filter/ipcd/ipcd \ vcl/source/filter/ipcx/ipcx \ vcl/source/filter/ipict/ipict \ diff --git a/vcl/inc/filter/PbmReader.hxx b/vcl/inc/filter/PbmReader.hxx new file mode 100644 index 000000000000..5fe4d8a295ef --- /dev/null +++ b/vcl/inc/filter/PbmReader.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/graph.hxx> + +VCL_DLLPUBLIC bool ImportPbmGraphic(SvStream& rStream, Graphic& rGraphic); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/qa/cppunit/data/pbm/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pbm/fail/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pbm/fail/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pbm/fail/.gitignore diff --git a/filter/qa/cppunit/data/pbm/fail/crash-1.pbm b/vcl/qa/cppunit/graphicfilter/data/pbm/fail/crash-1.pbm similarity index 100% rename from filter/qa/cppunit/data/pbm/fail/crash-1.pbm rename to vcl/qa/cppunit/graphicfilter/data/pbm/fail/crash-1.pbm diff --git a/filter/qa/cppunit/data/pbm/fail/hang-1.pbm b/vcl/qa/cppunit/graphicfilter/data/pbm/fail/hang-1.pbm similarity index 100% rename from filter/qa/cppunit/data/pbm/fail/hang-1.pbm rename to vcl/qa/cppunit/graphicfilter/data/pbm/fail/hang-1.pbm diff --git a/filter/qa/cppunit/data/pbm/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pbm/indeterminate/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pbm/indeterminate/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pbm/indeterminate/.gitignore diff --git a/filter/qa/cppunit/data/pbm/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pbm/pass/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pbm/pass/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pbm/pass/.gitignore diff --git a/filter/qa/cppunit/data/pbm/pass/rhbz160429-1.pbm b/vcl/qa/cppunit/graphicfilter/data/pbm/pass/rhbz160429-1.pbm similarity index 100% rename from filter/qa/cppunit/data/pbm/pass/rhbz160429-1.pbm rename to vcl/qa/cppunit/graphicfilter/data/pbm/pass/rhbz160429-1.pbm diff --git a/filter/qa/cppunit/data/ppm/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/ppm/fail/.gitignore similarity index 100% rename from filter/qa/cppunit/data/ppm/fail/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/ppm/fail/.gitignore diff --git a/filter/qa/cppunit/data/ppm/fail/CVE-2008-1097-1.ppm b/vcl/qa/cppunit/graphicfilter/data/ppm/fail/CVE-2008-1097-1.ppm similarity index 100% rename from filter/qa/cppunit/data/ppm/fail/CVE-2008-1097-1.ppm rename to vcl/qa/cppunit/graphicfilter/data/ppm/fail/CVE-2008-1097-1.ppm diff --git a/filter/qa/cppunit/data/ppm/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/ppm/indeterminate/.gitignore similarity index 100% rename from filter/qa/cppunit/data/ppm/indeterminate/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/ppm/indeterminate/.gitignore diff --git a/filter/qa/cppunit/data/ppm/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/ppm/pass/.gitignore similarity index 100% rename from filter/qa/cppunit/data/ppm/pass/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/ppm/pass/.gitignore diff --git a/filter/qa/cppunit/data/ppm/pass/fdo19811-2.ppm b/vcl/qa/cppunit/graphicfilter/data/ppm/pass/fdo19811-2.ppm similarity index 100% rename from filter/qa/cppunit/data/ppm/pass/fdo19811-2.ppm rename to vcl/qa/cppunit/graphicfilter/data/ppm/pass/fdo19811-2.ppm diff --git a/filter/qa/cppunit/filters-ppm-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-ppm-test.cxx similarity index 79% rename from filter/qa/cppunit/filters-ppm-test.cxx rename to vcl/qa/cppunit/graphicfilter/filters-ppm-test.cxx index 43ae966a0c57..c9c93a687d93 100644 --- a/filter/qa/cppunit/filters-ppm-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-ppm-test.cxx @@ -12,13 +12,7 @@ #include <vcl/FilterConfigItem.hxx> #include <tools/stream.hxx> #include <vcl/graph.hxx> - -extern "C" -{ - SAL_DLLPUBLIC_EXPORT bool SAL_CALL - ipbGraphicImport(SvStream & rStream, Graphic & rGraphic, - FilterConfigItem*); -} +#include <filter/PbmReader.hxx> using namespace ::com::sun::star; @@ -51,20 +45,20 @@ bool PpmFilterTest::load(const OUString &, { SvFileStream aFileStream(rURL, StreamMode::READ); Graphic aGraphic; - return ipbGraphicImport(aFileStream, aGraphic, nullptr); + return ImportPbmGraphic(aFileStream, aGraphic); } void PpmFilterTest::testCVEs() { +#ifndef DISABLE_CVE_TESTS testDir(OUString(), - m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/ppm/")); + m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/ppm/")); testDir(OUString(), - m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/pbm/")); + m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/pbm/")); +#endif } CPPUNIT_TEST_SUITE_REGISTRATION(PpmFilterTest); -CPPUNIT_PLUGIN_IMPLEMENT(); - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 9e5a1a236955..0f19f717f2c8 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -44,7 +44,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameLi IMP_BMP, IMP_GIF, IMP_PNG, IMP_JPEG, IMP_XBM, IMP_XPM, EXP_BMP, EXP_JPEG, EXP_PNG, IMP_MOV, IMP_TIFF, EXP_TIFF, IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, IMP_PCX, IMP_PSD, - IMP_PCD, nullptr + IMP_PCD, IMP_PBM, nullptr }; const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] = @@ -56,8 +56,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameL const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] = { - "egi", "ipb", "epb", "epg", - "epp", nullptr + "egi", "epb", "epg", "epp", nullptr }; void FilterConfigCache::FilterConfigCacheEntry::CreateFilterName( const OUString& rUserDataEntry ) @@ -238,9 +237,9 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] = "pcd","1","SVPCD", "psd","1","SVPSD", "pcx","1","SVPCX", - "pbm","1","ipb", - "pgm","1","ipb", - "ppm","1","ipb", + "pbm","1","SVPBM", + "pgm","1","SVPBM", + "ppm","1","SVPBM", "ras","1","SVRAS", "svm","1","SVMETAFILE", "svm","2","SVMETAFILE", diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 4d567e43565a..f76ede5dc840 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -58,6 +58,7 @@ #include <filter/EpsWriter.hxx> #include <filter/PsdReader.hxx> #include <filter/PcdReader.hxx> +#include <filter/PbmReader.hxx> #include <osl/module.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/Size.hpp> @@ -649,7 +650,6 @@ ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const OUString& rPathname, const #ifdef DISABLE_DYNLOADING extern "C" bool idxGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); -extern "C" bool ipbGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); #endif @@ -660,13 +660,9 @@ PFilterCall ImpFilterLibCacheEntry::GetImportFunction() #ifndef DISABLE_DYNLOADING if (maFormatName == "idx") mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("idxGraphicImport")); - else if (maFormatName == "ipb") - mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("ipbGraphicImport")); #else if (maFormatName == "idx") mpfnImport = idxGraphicImport; - else if (maFormatName == "ipb") - mpfnImport = ipbGraphicImport; #endif } @@ -1762,6 +1758,14 @@ ErrCode GraphicFilter::readPCD(SvStream & rStream, Graphic & rGraphic) return ERRCODE_GRFILTER_FILTERERROR; } +ErrCode GraphicFilter::readPBM(SvStream & rStream, Graphic & rGraphic) +{ + if (ImportPbmGraphic(rStream, rGraphic)) + return ERRCODE_NONE; + else + return ERRCODE_GRFILTER_FILTERERROR; +} + ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, SvStream& rIStream, sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags, const css::uno::Sequence< css::beans::PropertyValue >* /*pFilterData*/, @@ -1907,6 +1911,10 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, { nStatus = readPCD(rIStream, rGraphic); } + else if (aFilterName.equalsIgnoreAsciiCase(IMP_PBM)) + { + nStatus = readPBM(rIStream, rGraphic); + } else nStatus = ERRCODE_GRFILTER_FILTERERROR; } diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/vcl/source/filter/ipbm/ipbm.cxx similarity index 99% rename from filter/source/graphicfilter/ipbm/ipbm.cxx rename to vcl/source/filter/ipbm/ipbm.cxx index 4c12c18523fd..7794e611ef4c 100644 --- a/filter/source/graphicfilter/ipbm/ipbm.cxx +++ b/vcl/source/filter/ipbm/ipbm.cxx @@ -23,6 +23,7 @@ #include <vcl/graph.hxx> #include <vcl/BitmapTools.hxx> #include <tools/stream.hxx> +#include <filter/PbmReader.hxx> //============================ PBMReader ================================== @@ -530,8 +531,7 @@ bool PBMReader::ImplReadBody() //================== GraphicImport - the exported function ================ -extern "C" SAL_DLLPUBLIC_EXPORT bool -ipbGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) +bool ImportPbmGraphic( SvStream & rStream, Graphic & rGraphic) { PBMReader aPBMReader(rStream); diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index 02dc6d90eb21..45deeee37169 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -51,6 +51,7 @@ #include <filter/EpsReader.hxx> #include <filter/PsdReader.hxx> #include <filter/PcdReader.hxx> +#include <filter/PbmReader.hxx> #include <osl/file.hxx> #include <osl/module.hxx> #include <tools/stream.hxx> @@ -194,18 +195,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0) { - static PFilterCall pfnImport(nullptr); - if (!pfnImport) - { - osl::Module aLibrary; - aLibrary.loadRelative(&thisModule, "libgielo.so"); - pfnImport = reinterpret_cast<PFilterCall>( - aLibrary.getFunctionSymbol("ipbGraphicImport")); - aLibrary.release(); - } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); + ret = static_cast<int>(ImportPbmGraphic(aFileStream, aGraphic)); } else if (strcmp(argv[2], "psd") == 0) { diff --git a/vcl/workben/ppmfuzzer.cxx b/vcl/workben/ppmfuzzer.cxx index 854d457c5503..9595fa3aa747 100644 --- a/vcl/workben/ppmfuzzer.cxx +++ b/vcl/workben/ppmfuzzer.cxx @@ -10,6 +10,7 @@ #include <tools/stream.hxx> #include <vcl/FilterConfigItem.hxx> #include "commonfuzzer.hxx" +#include <filter/PbmReader.hxx> #include <config_features.h> #include <osl/detail/component-mapping.h> @@ -39,8 +40,6 @@ extern "C" void* lo_get_custom_widget_func(const char*) return nullptr; } -extern "C" bool ipbGraphicImport(SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem); - extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { TypicalFuzzerInitialize(argc, argv); @@ -51,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ); Graphic aGraphic; - (void)ipbGraphicImport(aStream, aGraphic, nullptr); + (void)ImportPbmGraphic(aStream, aGraphic); return 0; } commit 889220ff806242196d8a2064dab337862f1f3c80 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 10:23:27 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:34 2021 +0900 Move PCD reader from filter module into VCL Change-Id: Icd23d1343f5231c09dd8197943ca472f4b573bfc diff --git a/filter/CppunitTest_filter_pcd_test.mk b/filter/CppunitTest_filter_pcd_test.mk deleted file mode 100644 index 3741d5c9bf5a..000000000000 --- a/filter/CppunitTest_filter_pcd_test.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_CppunitTest_CppunitTest,filter_pcd_test)) - -$(eval $(call gb_CppunitTest_use_external,filter_pcd_test,boost_headers)) - -$(eval $(call gb_CppunitTest_add_exception_objects,filter_pcd_test, \ - filter/qa/cppunit/filters-pcd-test \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,filter_pcd_test, \ - gie \ - sal \ - test \ - tl \ - unotest \ - vcl \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,filter_pcd_test)) - -$(eval $(call gb_CppunitTest_use_ure,filter_pcd_test)) -$(eval $(call gb_CppunitTest_use_vcl,filter_pcd_test)) - -$(eval $(call gb_CppunitTest_use_components,filter_pcd_test,\ - configmgr/source/configmgr \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,filter_pcd_test)) - -# vim: set noet sw=4 ts=4: diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk index 29e7b131fae4..d5ab8b8169a5 100644 --- a/filter/Library_gie.mk +++ b/filter/Library_gie.mk @@ -60,7 +60,6 @@ $(eval $(call gb_Library_add_exception_objects,gie,\ filter/source/graphicfilter/idxf/dxftblrd \ filter/source/graphicfilter/idxf/dxfvec \ filter/source/graphicfilter/idxf/idxf \ - filter/source/graphicfilter/ipcd/ipcd \ )) # vim: set noet sw=4 ts=4: diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index 82eade49ffa1..678c882dce88 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -56,7 +56,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\ ifneq ($(DISABLE_CVE_TESTS),TRUE) $(eval $(call gb_Module_add_check_targets,filter,\ CppunitTest_filter_dxf_test \ - CppunitTest_filter_pcd_test \ CppunitTest_filter_ppm_test \ CppunitTest_filter_svg \ )) diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu index c5a0094b86e4..29c7b846ddae 100644 --- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="pcd_Import_Base" oor:op="replace" > - <prop oor:name="Type"><value>pcd_Photo_CD_Base</value></prop> - <prop oor:name="FormatName"><value>icd</value></prop> - <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PCD - Kodak Photo CD (768x512)</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="pcd_Import_Base" oor:op="replace" > + <prop oor:name="Type"><value>pcd_Photo_CD_Base</value></prop> + <prop oor:name="FormatName"><value>SVPCD</value></prop> + <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PCD - Kodak Photo CD (768x512)</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu index 27a471a2c75f..b61fde810697 100644 --- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base16.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="pcd_Import_Base16" oor:op="replace" > - <prop oor:name="Type"><value>pcd_Photo_CD_Base16</value></prop> - <prop oor:name="FormatName"><value>icd</value></prop> - <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base16</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PCD - Kodak Photo CD (192x128)</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="pcd_Import_Base16" oor:op="replace" > + <prop oor:name="Type"><value>pcd_Photo_CD_Base16</value></prop> + <prop oor:name="FormatName"><value>SVPCD</value></prop> + <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base16</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PCD - Kodak Photo CD (192x128)</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu index ba5f536b9a45..15d51918a09b 100644 --- a/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/pcd_Import_Base4.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="pcd_Import_Base4" oor:op="replace" > - <prop oor:name="Type"><value>pcd_Photo_CD_Base4</value></prop> - <prop oor:name="FormatName"><value>icd</value></prop> - <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base4</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PCD - Kodak Photo CD (384x256)</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="pcd_Import_Base4" oor:op="replace" > + <prop oor:name="Type"><value>pcd_Photo_CD_Base4</value></prop> + <prop oor:name="FormatName"><value>SVPCD</value></prop> + <prop oor:name="RealFilterName"><value>draw_PCD_Photo_CD_Base4</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PCD - Kodak Photo CD (384x256)</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 67d3beafe592..478e1c00a47a 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -85,6 +85,7 @@ namespace o3tl #define IMP_PCX "SVPCX" #define IMP_EPS "SVIEPS" #define IMP_PSD "SVPSD" +#define IMP_PCD "SVPCD" #define EXP_BMP "SVBMP" #define EXP_SVMETAFILE "SVMETAFILE" #define EXP_WMF "SVWMF" @@ -360,6 +361,7 @@ public: ErrCode readPCX(SvStream & rStream, Graphic & rGraphic); ErrCode readEPS(SvStream & rStream, Graphic & rGraphic); ErrCode readPSD(SvStream & rStream, Graphic & rGraphic); + ErrCode readPCD(SvStream & rStream, Graphic & rGraphic); private: OUString aFilterPath; diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index ad2fd2c6c8be..b7118132d5c2 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3891,7 +3891,6 @@ external/unixODBC/inc/odbc/sqltypes.h external/unixODBC/inc/odbc/sqlucode.h filter/inc/strings.hxx filter/qa/cppunit/filters-dxf-test.cxx -filter/qa/cppunit/filters-pcd-test.cxx filter/qa/cppunit/filters-ppm-test.cxx filter/qa/cppunit/msfilter-test.cxx filter/qa/cppunit/priority-test.cxx @@ -3959,7 +3958,6 @@ filter/source/graphicfilter/idxf/dxfvec.cxx filter/source/graphicfilter/idxf/dxfvec.hxx filter/source/graphicfilter/idxf/idxf.cxx filter/source/graphicfilter/ipbm/ipbm.cxx -filter/source/graphicfilter/ipcd/ipcd.cxx filter/source/msfilter/countryid.cxx filter/source/msfilter/dffpropset.cxx filter/source/msfilter/escherex.cxx @@ -14809,6 +14807,7 @@ vcl/qa/cppunit/font.cxx vcl/qa/cppunit/fontmetric.cxx vcl/qa/cppunit/graphicfilter/filters-eps-test.cxx vcl/qa/cppunit/graphicfilter/filters-met-test.cxx +vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx vcl/qa/cppunit/graphicfilter/filters-pcx-test.cxx vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx vcl/qa/cppunit/graphicfilter/filters-psd-test.cxx @@ -14926,6 +14925,7 @@ vcl/source/filter/igif/decode.cxx vcl/source/filter/igif/decode.hxx vcl/source/filter/igif/gifread.cxx vcl/source/filter/imet/ios2met.cxx +vcl/source/filter/ipcd/ipcd.cxx vcl/source/filter/ipcx/ipcx.cxx vcl/source/filter/ipict/ipict.cxx vcl/source/filter/ipsd/ipsd.cxx diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk index a62e3b109927..8ebc4c7c1ae0 100644 --- a/vcl/CppunitTest_vcl_filters_test.mk +++ b/vcl/CppunitTest_vcl_filters_test.mk @@ -12,6 +12,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,vcl_filters_test)) $(eval $(call gb_CppunitTest_add_exception_objects,vcl_filters_test, \ vcl/qa/cppunit/graphicfilter/filters-eps-test \ vcl/qa/cppunit/graphicfilter/filters-met-test \ + vcl/qa/cppunit/graphicfilter/filters-pcd-test \ vcl/qa/cppunit/graphicfilter/filters-pcx-test \ vcl/qa/cppunit/graphicfilter/filters-pict-test \ vcl/qa/cppunit/graphicfilter/filters-psd-test \ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 6d73b8850f55..34b7f0697436 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -440,6 +440,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/igif/decode \ vcl/source/filter/igif/gifread \ vcl/source/filter/imet/ios2met \ + vcl/source/filter/ipcd/ipcd \ vcl/source/filter/ipcx/ipcx \ vcl/source/filter/ipict/ipict \ vcl/source/filter/ipsd/ipsd \ diff --git a/vcl/inc/filter/PcdReader.hxx b/vcl/inc/filter/PcdReader.hxx new file mode 100644 index 000000000000..216a14b89040 --- /dev/null +++ b/vcl/inc/filter/PcdReader.hxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/graph.hxx> +#include <vcl/FilterConfigItem.hxx> + +VCL_DLLPUBLIC bool ImportPcdGraphic(SvStream& rStream, Graphic& rGraphic, + FilterConfigItem* pFilterConfigItem); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/qa/cppunit/data/pcd/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pcd/fail/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pcd/fail/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pcd/fail/.gitignore diff --git a/filter/qa/cppunit/data/pcd/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pcd/indeterminate/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pcd/indeterminate/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pcd/indeterminate/.gitignore diff --git a/filter/qa/cppunit/data/pcd/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pcd/pass/.gitignore similarity index 100% rename from filter/qa/cppunit/data/pcd/pass/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/pcd/pass/.gitignore diff --git a/filter/qa/cppunit/data/pcd/pass/blank-square.pcd b/vcl/qa/cppunit/graphicfilter/data/pcd/pass/blank-square.pcd similarity index 100% rename from filter/qa/cppunit/data/pcd/pass/blank-square.pcd rename to vcl/qa/cppunit/graphicfilter/data/pcd/pass/blank-square.pcd diff --git a/filter/qa/cppunit/filters-pcd-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx similarity index 80% rename from filter/qa/cppunit/filters-pcd-test.cxx rename to vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx index dc32e33469e7..bd100c8f2090 100644 --- a/filter/qa/cppunit/filters-pcd-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-pcd-test.cxx @@ -12,15 +12,9 @@ #include <vcl/FilterConfigItem.hxx> #include <tools/stream.hxx> #include <vcl/graph.hxx> +#include <filter/PcdReader.hxx> -extern "C" -{ - SAL_DLLPUBLIC_EXPORT bool SAL_CALL - icdGraphicImport(SvStream & rStream, Graphic & rGraphic, - FilterConfigItem*); -} - -using namespace ::com::sun::star; +using namespace css; /* Implementation of Filters test */ @@ -51,17 +45,17 @@ bool PcdFilterTest::load(const OUString &, { SvFileStream aFileStream(rURL, StreamMode::READ); Graphic aGraphic; - return icdGraphicImport(aFileStream, aGraphic, nullptr); + return ImportPcdGraphic(aFileStream, aGraphic, nullptr); } void PcdFilterTest::testCVEs() { +#ifndef DISABLE_CVE_TESTS testDir(OUString(), - m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/pcd/")); + m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/pcd/")); +#endif } CPPUNIT_TEST_SUITE_REGISTRATION(PcdFilterTest); -CPPUNIT_PLUGIN_IMPLEMENT(); - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index e3752a24a7c6..9e5a1a236955 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -43,7 +43,8 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalPixelFilterNameLi { IMP_BMP, IMP_GIF, IMP_PNG, IMP_JPEG, IMP_XBM, IMP_XPM, EXP_BMP, EXP_JPEG, EXP_PNG, IMP_MOV, IMP_TIFF, EXP_TIFF, - IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, IMP_PCX, IMP_PSD, nullptr + IMP_TGA, IMP_PICT, IMP_MET, IMP_RAS, IMP_PCX, IMP_PSD, + IMP_PCD, nullptr }; const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] = @@ -55,7 +56,7 @@ const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameL const char* FilterConfigCache::FilterConfigCacheEntry::ExternalPixelFilterNameList[] = { - "egi", "icd", "ipb", "epb", "epg", + "egi", "ipb", "epb", "epg", "epp", nullptr }; @@ -234,7 +235,7 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] = "png","1","SVIPNG", "png","2","SVEPNG", "pct","1","SVPICT", - "pcd","1","icd", + "pcd","1","SVPCD", "psd","1","SVPSD", "pcx","1","SVPCX", "pbm","1","ipb", diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 5ebff94f173c..4d567e43565a 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -57,6 +57,7 @@ #include <filter/EpsReader.hxx> #include <filter/EpsWriter.hxx> #include <filter/PsdReader.hxx> +#include <filter/PcdReader.hxx> #include <osl/module.hxx> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/Size.hpp> @@ -647,7 +648,6 @@ ImpFilterLibCacheEntry::ImpFilterLibCacheEntry( const OUString& rPathname, const #ifdef DISABLE_DYNLOADING -extern "C" bool icdGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); extern "C" bool idxGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); extern "C" bool ipbGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem ); @@ -658,16 +658,12 @@ PFilterCall ImpFilterLibCacheEntry::GetImportFunction() if( !mpfnImport ) { #ifndef DISABLE_DYNLOADING - if (maFormatName == "icd") - mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("icdGraphicImport")); - else if (maFormatName == "idx") + if (maFormatName == "idx") mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("idxGraphicImport")); else if (maFormatName == "ipb") mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("ipbGraphicImport")); #else - if (maFormatName == "icd") - mpfnImport = icdGraphicImport; - else if (maFormatName == "idx") + if (maFormatName == "idx") mpfnImport = idxGraphicImport; else if (maFormatName == "ipb") mpfnImport = ipbGraphicImport; @@ -1405,7 +1401,7 @@ void GraphicFilter::preload() sal_Int32 nTokenCount = comphelper::string::getTokenCount(aFilterPath, ';'); ImpFilterLibCache& rCache = Cache::get(); static const std::initializer_list<std::u16string_view> aFilterNames = { - u"icd", u"idx", u"ipb", u"ipd" + u"idx", u"ipb", u"ipd" }; // Load library for each filter. @@ -1751,6 +1747,21 @@ ErrCode GraphicFilter::readPSD(SvStream & rStream, Graphic & rGraphic) return ERRCODE_GRFILTER_FILTERERROR; } +ErrCode GraphicFilter::readPCD(SvStream & rStream, Graphic & rGraphic) +{ + std::unique_ptr<FilterConfigItem> pFilterConfigItem; + if (!utl::ConfigManager::IsFuzzing()) + { + OUString aFilterConfigPath( "Office.Common/Filter/Graphic/Import/PCD" ); + pFilterConfigItem = std::make_unique<FilterConfigItem>(aFilterConfigPath); + } + + if (ImportPcdGraphic(rStream, rGraphic, pFilterConfigItem.get())) + return ERRCODE_NONE; + else + return ERRCODE_GRFILTER_FILTERERROR; +} + ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, SvStream& rIStream, sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags, const css::uno::Sequence< css::beans::PropertyValue >* /*pFilterData*/, @@ -1892,6 +1903,10 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, { nStatus = readPSD(rIStream, rGraphic); } + else if (aFilterName.equalsIgnoreAsciiCase(IMP_PCD)) + { + nStatus = readPCD(rIStream, rGraphic); + } else nStatus = ERRCODE_GRFILTER_FILTERERROR; } @@ -1919,18 +1934,7 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath, nStatus = ERRCODE_GRFILTER_FILTERERROR; else { - std::unique_ptr<FilterConfigItem> pFilterConfigItem; - OUString aShortName; - if( nFormat != GRFILTER_FORMAT_DONTKNOW ) - { - aShortName = GetImportFormatShortName( nFormat ).toAsciiUpperCase(); - if (aShortName == "PCD" && !utl::ConfigManager::IsFuzzing()) - { - OUString aFilterConfigPath( "Office.Common/Filter/Graphic/Import/PCD" ); - pFilterConfigItem = std::make_unique<FilterConfigItem>( aFilterConfigPath ); - } - } - if( !(*pFunc)( rIStream, rGraphic, pFilterConfigItem.get() ) ) + if( !(*pFunc)( rIStream, rGraphic, nullptr ) ) nStatus = ERRCODE_GRFILTER_FORMATERROR; } } diff --git a/filter/source/graphicfilter/ipcd/ipcd.cxx b/vcl/source/filter/ipcd/ipcd.cxx similarity index 98% rename from filter/source/graphicfilter/ipcd/ipcd.cxx rename to vcl/source/filter/ipcd/ipcd.cxx index b2b585606286..5072e2ab4354 100644 --- a/filter/source/graphicfilter/ipcd/ipcd.cxx +++ b/vcl/source/filter/ipcd/ipcd.cxx @@ -22,6 +22,7 @@ #include <vcl/BitmapTools.hxx> #include <vcl/FilterConfigItem.hxx> #include <tools/stream.hxx> +#include <filter/PcdReader.hxx> //============================ PCDReader ================================== @@ -353,8 +354,7 @@ void PCDReader::ReadImage() //================== GraphicImport - the exported Function ================ -extern "C" SAL_DLLPUBLIC_EXPORT bool -icdGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pConfigItem ) +bool ImportPcdGraphic(SvStream & rStream, Graphic & rGraphic, FilterConfigItem* pConfigItem) { PCDReader aPCDReader(rStream); return aPCDReader.ReadPCD(rGraphic, pConfigItem); diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index fe030475e3f8..02dc6d90eb21 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -50,6 +50,7 @@ #include <filter/PcxReader.hxx> #include <filter/EpsReader.hxx> #include <filter/PsdReader.hxx> +#include <filter/PcdReader.hxx> #include <osl/file.hxx> #include <osl/module.hxx> #include <tools/stream.hxx> @@ -166,18 +167,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) #ifndef DISABLE_DYNLOADING else if (strcmp(argv[2], "pcd") == 0) { - static PFilterCall pfnImport(nullptr); - if (!pfnImport) - { - osl::Module aLibrary; - aLibrary.loadRelative(&thisModule, "libgielo.so"); - pfnImport = reinterpret_cast<PFilterCall>( - aLibrary.getFunctionSymbol("icdGraphicImport")); - aLibrary.release(); - } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); + ret = static_cast<int>(ImportPcdGraphic(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "dxf") == 0) { diff --git a/vcl/workben/pcdfuzzer.cxx b/vcl/workben/pcdfuzzer.cxx index ccd0367535be..86df131da1cc 100644 --- a/vcl/workben/pcdfuzzer.cxx +++ b/vcl/workben/pcdfuzzer.cxx @@ -10,6 +10,7 @@ #include <tools/stream.hxx> #include <vcl/FilterConfigItem.hxx> #include "commonfuzzer.hxx" +#include <filter/PcdReader.hxx> #include <config_features.h> #include <osl/detail/component-mapping.h> @@ -39,8 +40,6 @@ extern "C" void* lo_get_custom_widget_func(const char*) return nullptr; } -extern "C" bool icdGraphicImport(SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem); - extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { TypicalFuzzerInitialize(argc, argv); @@ -51,7 +50,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ); Graphic aGraphic; - (void)icdGraphicImport(aStream, aGraphic, nullptr); + (void)ImportPcdGraphic(aStream, aGraphic, nullptr); return 0; } commit ce029b3b6b082e3ac0258d4ecd76ab74a6bff45a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Feb 15 09:57:51 2021 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon Feb 15 16:27:34 2021 +0900 Move PSD reader from filter module into VCL Change-Id: I53b11be6e9eb0013f017b2da5745ff525ca79c54 diff --git a/filter/CppunitTest_filter_psd_test.mk b/filter/CppunitTest_filter_psd_test.mk deleted file mode 100644 index 22a2531eb43f..000000000000 --- a/filter/CppunitTest_filter_psd_test.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_CppunitTest_CppunitTest,filter_psd_test)) - -$(eval $(call gb_CppunitTest_use_external,filter_psd_test,boost_headers)) - -$(eval $(call gb_CppunitTest_add_exception_objects,filter_psd_test, \ - filter/qa/cppunit/filters-psd-test \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,filter_psd_test, \ - gie \ - sal \ - test \ - tl \ - unotest \ - vcl \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,filter_psd_test)) - -$(eval $(call gb_CppunitTest_use_ure,filter_psd_test)) -$(eval $(call gb_CppunitTest_use_vcl,filter_psd_test)) - -$(eval $(call gb_CppunitTest_use_components,filter_psd_test,\ - configmgr/source/configmgr \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,filter_psd_test)) - -# vim: set noet sw=4 ts=4: diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk index d013b58ee489..29e7b131fae4 100644 --- a/filter/Library_gie.mk +++ b/filter/Library_gie.mk @@ -51,7 +51,6 @@ $(eval $(call gb_Library_use_libraries,gie,\ $(eval $(call gb_Library_add_exception_objects,gie,\ filter/source/graphicfilter/egif/egif \ filter/source/graphicfilter/egif/giflzwc \ - filter/source/graphicfilter/ipsd/ipsd \ filter/source/graphicfilter/ipbm/ipbm \ filter/source/graphicfilter/idxf/dxf2mtf \ filter/source/graphicfilter/idxf/dxfblkrd \ diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index dd81f672df66..82eade49ffa1 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -58,7 +58,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\ CppunitTest_filter_dxf_test \ CppunitTest_filter_pcd_test \ CppunitTest_filter_ppm_test \ - CppunitTest_filter_psd_test \ CppunitTest_filter_svg \ )) endif diff --git a/filter/source/config/fragments/internalgraphicfilters/psd_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/psd_Import.xcu index ce2c3066b8da..f51b0fa59d48 100644 --- a/filter/source/config/fragments/internalgraphicfilters/psd_Import.xcu +++ b/filter/source/config/fragments/internalgraphicfilters/psd_Import.xcu @@ -15,13 +15,14 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . --> - <node oor:name="psd_Import" oor:op="replace" > - <prop oor:name="Type"><value>psd_Adobe_Photoshop</value></prop> - <prop oor:name="FormatName"><value>ipd</value></prop> - <prop oor:name="RealFilterName"><value>PSD - Adobe Photoshop</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UIName"> - <value xml:lang="en-US">PSD - Adobe Photoshop</value> - </prop> - <prop oor:name="Flags"><value>IMPORT</value></prop> - </node> + +<node oor:name="psd_Import" oor:op="replace" > + <prop oor:name="Type"><value>psd_Adobe_Photoshop</value></prop> + <prop oor:name="FormatName"><value>SVPSD</value></prop> + <prop oor:name="RealFilterName"><value>PSD - Adobe Photoshop</value></prop> + <prop oor:name="UIComponent"/> + <prop oor:name="UIName"> + <value xml:lang="en-US">PSD - Adobe Photoshop</value> + </prop> + <prop oor:name="Flags"><value>IMPORT</value></prop> +</node> diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 44852bfb746c..67d3beafe592 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -84,6 +84,7 @@ namespace o3tl #define IMP_RAS "SVRAS" #define IMP_PCX "SVPCX" #define IMP_EPS "SVIEPS" +#define IMP_PSD "SVPSD" #define EXP_BMP "SVBMP" #define EXP_SVMETAFILE "SVMETAFILE" #define EXP_WMF "SVWMF" @@ -358,6 +359,7 @@ public: ErrCode readRAS(SvStream & rStream, Graphic & rGraphic); ErrCode readPCX(SvStream & rStream, Graphic & rGraphic); ErrCode readEPS(SvStream & rStream, Graphic & rGraphic); + ErrCode readPSD(SvStream & rStream, Graphic & rGraphic); private: OUString aFilterPath; diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 89e402cc68d8..ad2fd2c6c8be 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -3893,7 +3893,6 @@ filter/inc/strings.hxx filter/qa/cppunit/filters-dxf-test.cxx filter/qa/cppunit/filters-pcd-test.cxx filter/qa/cppunit/filters-ppm-test.cxx -filter/qa/cppunit/filters-psd-test.cxx filter/qa/cppunit/msfilter-test.cxx filter/qa/cppunit/priority-test.cxx filter/qa/cppunit/xslt-test.cxx @@ -3961,7 +3960,6 @@ filter/source/graphicfilter/idxf/dxfvec.hxx filter/source/graphicfilter/idxf/idxf.cxx filter/source/graphicfilter/ipbm/ipbm.cxx filter/source/graphicfilter/ipcd/ipcd.cxx -filter/source/graphicfilter/ipsd/ipsd.cxx filter/source/msfilter/countryid.cxx filter/source/msfilter/dffpropset.cxx filter/source/msfilter/escherex.cxx @@ -14813,6 +14811,7 @@ vcl/qa/cppunit/graphicfilter/filters-eps-test.cxx vcl/qa/cppunit/graphicfilter/filters-met-test.cxx vcl/qa/cppunit/graphicfilter/filters-pcx-test.cxx vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx +vcl/qa/cppunit/graphicfilter/filters-psd-test.cxx vcl/qa/cppunit/graphicfilter/filters-ras-test.cxx vcl/qa/cppunit/graphicfilter/filters-test.cxx vcl/qa/cppunit/graphicfilter/filters-tga-test.cxx @@ -14929,6 +14928,7 @@ vcl/source/filter/igif/gifread.cxx vcl/source/filter/imet/ios2met.cxx vcl/source/filter/ipcx/ipcx.cxx vcl/source/filter/ipict/ipict.cxx +vcl/source/filter/ipsd/ipsd.cxx vcl/source/filter/ipict/shape.cxx vcl/source/filter/ipict/shape.hxx vcl/source/filter/iras/iras.cxx diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk index a84aec4c22ec..a62e3b109927 100644 --- a/vcl/CppunitTest_vcl_filters_test.mk +++ b/vcl/CppunitTest_vcl_filters_test.mk @@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_filters_test, \ vcl/qa/cppunit/graphicfilter/filters-met-test \ vcl/qa/cppunit/graphicfilter/filters-pcx-test \ vcl/qa/cppunit/graphicfilter/filters-pict-test \ + vcl/qa/cppunit/graphicfilter/filters-psd-test \ vcl/qa/cppunit/graphicfilter/filters-ras-test \ vcl/qa/cppunit/graphicfilter/filters-test \ vcl/qa/cppunit/graphicfilter/filters-tiff-test \ diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 3642efc7978c..6d73b8850f55 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -442,6 +442,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/filter/imet/ios2met \ vcl/source/filter/ipcx/ipcx \ vcl/source/filter/ipict/ipict \ + vcl/source/filter/ipsd/ipsd \ vcl/source/filter/ipict/shape \ vcl/source/filter/ipdf/pdfread \ vcl/source/filter/ipdf/pdfdocument \ diff --git a/vcl/inc/filter/PsdReader.hxx b/vcl/inc/filter/PsdReader.hxx new file mode 100644 index 000000000000..a257f04d4334 --- /dev/null +++ b/vcl/inc/filter/PsdReader.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <vcl/graph.hxx> + +VCL_DLLPUBLIC bool ImportPsdGraphic(SvStream& rStream, Graphic& rGraphic); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/qa/cppunit/data/psd/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/psd/fail/.gitignore similarity index 100% rename from filter/qa/cppunit/data/psd/fail/.gitignore rename to vcl/qa/cppunit/graphicfilter/data/psd/fail/.gitignore ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits