[Libreoffice-commits] core.git: filter/CppunitTest_filter_pict_test.mk filter/Library_gie.mk filter/Module_filter.mk filter/qa filter/source include/vcl solenv/clang-format vcl/CppunitTest_vcl_filters_test.mk vcl/inc vcl/Library_vcl.mk vcl/qa vcl/source vcl/workben

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 17 01:44:42 UTC 2021


 filter/CppunitTest_filter_pict_test.mk                               |   50 ----------
 filter/Library_gie.mk                                                |    2 
 filter/Module_filter.mk                                              |    1 
 filter/source/config/fragments/internalgraphicfilters/pct_Import.xcu |   21 ++--
 filter/source/graphicfilter/ipict/ipict.hxx                          |   26 -----
 include/vcl/graphicfilter.hxx                                        |    2 
 solenv/clang-format/excludelist                                      |    8 -
 vcl/CppunitTest_vcl_filters_test.mk                                  |    6 +
 vcl/Library_vcl.mk                                                   |    2 
 vcl/inc/filter/PictReader.hxx                                        |   33 ++++++
 vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx                   |   22 +---
 vcl/source/filter/FilterConfigCache.cxx                              |    5 -
 vcl/source/filter/graphicfilter.cxx                                  |   35 ++++---
 vcl/source/filter/ipict/ipict.cxx                                    |   12 --
 vcl/workben/fftester.cxx                                             |   12 --
 vcl/workben/pctfuzzer.cxx                                            |    5 -
 16 files changed, 95 insertions(+), 147 deletions(-)

New commits:
commit 4d22e3ce32959d795a90653807c1c19cc9c1838e
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Feb 14 22:26:00 2021 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Feb 17 02:43:45 2021 +0100

    Move PICT reader from filter module into VCL
    
    Change-Id: I6d3a28769ff3bffa3970a4ab6ab2384bb0aebbca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111011
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/filter/CppunitTest_filter_pict_test.mk b/filter/CppunitTest_filter_pict_test.mk
deleted file mode 100644
index 431166e6e3cd..000000000000
--- a/filter/CppunitTest_filter_pict_test.mk
+++ /dev/null
@@ -1,50 +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_pict_test))
-
-$(eval $(call gb_CppunitTest_use_externals,filter_pict_test,\
-	boost_headers \
-	libxml2 \
-))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,filter_pict_test, \
-    filter/qa/cppunit/filters-pict-test \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,filter_pict_test, \
-	cppu \
-	comphelper \
-	basegfx \
-	sal \
-	salhelper \
-	test \
-	tk \
-	tl \
-	utl \
-	unotest \
-	vcl \
-))
-
-$(eval $(call gb_CppunitTest_use_library_objects,filter_pict_test, \
-    gie \
-))
-
-$(eval $(call gb_CppunitTest_use_sdk_api,filter_pict_test))
-
-$(eval $(call gb_CppunitTest_use_ure,filter_pict_test))
-$(eval $(call gb_CppunitTest_use_vcl,filter_pict_test))
-
-$(eval $(call gb_CppunitTest_use_components,filter_pict_test,\
-    configmgr/source/configmgr \
-    i18npool/util/i18npool \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,filter_pict_test))
-
-# vim: set noet sw=4 ts=4:
diff --git a/filter/Library_gie.mk b/filter/Library_gie.mk
index be60d68e3de7..4f383a0770bd 100644
--- a/filter/Library_gie.mk
+++ b/filter/Library_gie.mk
@@ -52,8 +52,6 @@ $(eval $(call gb_Library_add_exception_objects,gie,\
     filter/source/graphicfilter/egif/egif \
     filter/source/graphicfilter/eps/eps \
     filter/source/graphicfilter/egif/giflzwc \
-    filter/source/graphicfilter/ipict/ipict \
-    filter/source/graphicfilter/ipict/shape \
     filter/source/graphicfilter/ipcx/ipcx \
     filter/source/graphicfilter/iras/iras \
     filter/source/graphicfilter/ieps/ieps \
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index a998c65b60ab..18481a33c0e1 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -60,7 +60,6 @@ $(eval $(call gb_Module_add_check_targets,filter,\
     CppunitTest_filter_met_test \
     CppunitTest_filter_pcd_test \
     CppunitTest_filter_pcx_test \
-    CppunitTest_filter_pict_test \
     CppunitTest_filter_ppm_test \
     CppunitTest_filter_psd_test \
     CppunitTest_filter_ras_test \
diff --git a/filter/source/config/fragments/internalgraphicfilters/pct_Import.xcu b/filter/source/config/fragments/internalgraphicfilters/pct_Import.xcu
index 63048f9b4eb2..974bb330066b 100644
--- a/filter/source/config/fragments/internalgraphicfilters/pct_Import.xcu
+++ b/filter/source/config/fragments/internalgraphicfilters/pct_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="pct_Import" oor:op="replace"  >
-        <prop oor:name="Type"><value>pct_Mac_Pict</value></prop>
-        <prop oor:name="FormatName"><value>ipt</value></prop>
-        <prop oor:name="RealFilterName"><value>PCT - Mac Pict</value></prop>
-        <prop oor:name="UIComponent"/>
-        <prop oor:name="UIName">
-            <value xml:lang="en-US">PCT - Mac Pict</value>
-        </prop>
-        <prop oor:name="Flags"><value>IMPORT</value></prop>
-    </node>
+
+<node oor:name="pct_Import" oor:op="replace"  >
+    <prop oor:name="Type"><value>pct_Mac_Pict</value></prop>
+    <prop oor:name="FormatName"><value>SVPICT</value></prop>
+    <prop oor:name="RealFilterName"><value>PCT - Mac Pict</value></prop>
+    <prop oor:name="UIComponent"/>
+    <prop oor:name="UIName">
+        <value xml:lang="en-US">PCT - Mac Pict</value>
+    </prop>
+    <prop oor:name="Flags"><value>IMPORT</value></prop>
+</node>
diff --git a/filter/source/graphicfilter/ipict/ipict.hxx b/filter/source/graphicfilter/ipict/ipict.hxx
deleted file mode 100644
index 31ffdac0a81e..000000000000
--- a/filter/source/graphicfilter/ipict/ipict.hxx
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -*- 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/.
- */
-
-#ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
-#define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
-
-#include <sal/config.h>
-
-class GDIMetaFile;
-class SvStream;
-
-namespace pict
-{
-/// Function to access PictReader::ReadPict for unit testing.
-void ReadPictFile(SvStream& rStreamPict, GDIMetaFile& rGDIMetaFile);
-}
-
-#endif // INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 4c0f2b4a339d..055fa895a353 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -80,6 +80,7 @@ namespace o3tl
 #define IMP_PDF                 "SVIPDF"
 #define IMP_TIFF                "SVTIFF"
 #define IMP_TGA                 "SVTGA"
+#define IMP_PICT                "SVPICT"
 #define EXP_BMP                 "SVBMP"
 #define EXP_SVMETAFILE          "SVMETAFILE"
 #define EXP_WMF                 "SVWMF"
@@ -362,6 +363,7 @@ public:
     static ErrCode readTIFF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);
     static ErrCode readWithTypeSerializer(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, OUString aFilterName);
     static ErrCode readTGA(SvStream & rStream, Graphic & rGraphic);
+    static ErrCode readPICT(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);
 
 private:
     OUString        aFilterPath;
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index b8d95a0fad42..312b98050cb7 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -3902,7 +3902,6 @@ filter/qa/cppunit/filters-eps-test.cxx
 filter/qa/cppunit/filters-met-test.cxx
 filter/qa/cppunit/filters-pcd-test.cxx
 filter/qa/cppunit/filters-pcx-test.cxx
-filter/qa/cppunit/filters-pict-test.cxx
 filter/qa/cppunit/filters-ppm-test.cxx
 filter/qa/cppunit/filters-psd-test.cxx
 filter/qa/cppunit/filters-ras-test.cxx
@@ -3977,9 +3976,6 @@ filter/source/graphicfilter/ios2met/ios2met.cxx
 filter/source/graphicfilter/ipbm/ipbm.cxx
 filter/source/graphicfilter/ipcd/ipcd.cxx
 filter/source/graphicfilter/ipcx/ipcx.cxx
-filter/source/graphicfilter/ipict/ipict.cxx
-filter/source/graphicfilter/ipict/shape.cxx
-filter/source/graphicfilter/ipict/shape.hxx
 filter/source/graphicfilter/ipsd/ipsd.cxx
 filter/source/graphicfilter/iras/iras.cxx
 filter/source/msfilter/countryid.cxx
@@ -14827,6 +14823,7 @@ vcl/qa/cppunit/font.cxx
 vcl/qa/cppunit/fontmetric.cxx
 vcl/qa/cppunit/graphicfilter/filters-test.cxx
 vcl/qa/cppunit/graphicfilter/filters-tga-test.cxx
+vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx
 vcl/qa/cppunit/lifecycle.cxx
 vcl/qa/cppunit/svm/svmtest.cxx
 vcl/qa/cppunit/timer.cxx
@@ -14935,6 +14932,9 @@ vcl/source/filter/etiff/etiff.cxx
 vcl/source/filter/igif/decode.cxx
 vcl/source/filter/igif/decode.hxx
 vcl/source/filter/igif/gifread.cxx
+vcl/source/filter/ipict/ipict.cxx
+vcl/source/filter/ipict/shape.cxx
+vcl/source/filter/ipict/shape.hxx
 vcl/source/filter/ixbm/xbmread.cxx
 vcl/source/filter/ixpm/rgbtable.hxx
 vcl/source/filter/ixpm/xpmread.cxx
diff --git a/vcl/CppunitTest_vcl_filters_test.mk b/vcl/CppunitTest_vcl_filters_test.mk
index bd4131f3983e..3d958cc7f7ad 100644
--- a/vcl/CppunitTest_vcl_filters_test.mk
+++ b/vcl/CppunitTest_vcl_filters_test.mk
@@ -13,6 +13,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,vcl_filters_test, \
     vcl/qa/cppunit/graphicfilter/filters-test \
     vcl/qa/cppunit/graphicfilter/filters-tiff-test \
     vcl/qa/cppunit/graphicfilter/filters-tga-test \
+    vcl/qa/cppunit/graphicfilter/filters-pict-test \
 ))
 
 $(eval $(call gb_CppunitTest_set_include,vcl_filters_test,\
@@ -26,7 +27,10 @@ $(eval $(call gb_CppunitTest_add_defs,vcl_filters_test,\
 ))
 endif
 
-$(eval $(call gb_CppunitTest_use_external,vcl_filters_test,boost_headers))
+$(eval $(call gb_CppunitTest_use_externals,vcl_filters_test,\
+	boost_headers \
+	libxml2 \
+))
 
 $(eval $(call gb_CppunitTest_use_libraries,vcl_filters_test, \
 	comphelper \
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a19125934bc0..7b4701995b3e 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -438,6 +438,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/igif/decode \
     vcl/source/filter/igif/gifread \
     vcl/source/filter/itga/itga \
+    vcl/source/filter/ipict/ipict \
+    vcl/source/filter/ipict/shape \
     vcl/source/filter/ipdf/pdfread \
     vcl/source/filter/ipdf/pdfdocument \
     vcl/source/filter/itiff/ccidecom \
diff --git a/vcl/inc/filter/PictReader.hxx b/vcl/inc/filter/PictReader.hxx
new file mode 100644
index 000000000000..fa3fb09a006b
--- /dev/null
+++ b/vcl/inc/filter/PictReader.hxx
@@ -0,0 +1,33 @@
+/* -*- 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 <sal/config.h>
+
+class GDIMetaFile;
+class SvStream;
+
+VCL_DLLPUBLIC bool ImportPictGraphic(SvStream& rStream, Graphic& rGraphic);
+
+/// Function to access PictReader::ReadPict for unit testing.
+VCL_DLLPUBLIC void ReadPictFile(SvStream& rStreamPict, GDIMetaFile& rGDIMetaFile);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/qa/cppunit/data/pict/clipping-problem.pct b/vcl/qa/cppunit/graphicfilter/data/pict/clipping-problem.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/clipping-problem.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/clipping-problem.pct
diff --git a/filter/qa/cppunit/data/pict/fail/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/fail/.gitignore
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/.gitignore
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/.gitignore
diff --git a/filter/qa/cppunit/data/pict/fail/CVE-2008-1097-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2008-1097-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/CVE-2008-1097-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2008-1097-1.pct
diff --git a/filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2012-0277-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/CVE-2012-0277-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2012-0277-1.pct
diff --git a/filter/qa/cppunit/data/pict/fail/CVE-2013-2577-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2013-2577-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/CVE-2013-2577-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/CVE-2013-2577-1.pct
diff --git a/filter/qa/cppunit/data/pict/fail/EDB-19332-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/EDB-19332-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/EDB-19332-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/EDB-19332-1.pct
diff --git a/filter/qa/cppunit/data/pict/fail/exception-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/exception-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/exception-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/exception-1.pct
diff --git a/filter/qa/cppunit/data/pict/fail/hang-1.pct b/vcl/qa/cppunit/graphicfilter/data/pict/fail/hang-1.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/fail/hang-1.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/fail/hang-1.pct
diff --git a/filter/qa/cppunit/data/pict/indeterminate/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/indeterminate/.gitignore
similarity index 100%
rename from filter/qa/cppunit/data/pict/indeterminate/.gitignore
rename to vcl/qa/cppunit/graphicfilter/data/pict/indeterminate/.gitignore
diff --git a/filter/qa/cppunit/data/pict/pass/.gitignore b/vcl/qa/cppunit/graphicfilter/data/pict/pass/.gitignore
similarity index 100%
rename from filter/qa/cppunit/data/pict/pass/.gitignore
rename to vcl/qa/cppunit/graphicfilter/data/pict/pass/.gitignore
diff --git a/filter/qa/cppunit/data/pict/pass/ooo25876-2.pct b/vcl/qa/cppunit/graphicfilter/data/pict/pass/ooo25876-2.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/pass/ooo25876-2.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/pass/ooo25876-2.pct
diff --git a/filter/qa/cppunit/data/pict/pass/tdf92789.pct b/vcl/qa/cppunit/graphicfilter/data/pict/pass/tdf92789.pct
similarity index 100%
rename from filter/qa/cppunit/data/pict/pass/tdf92789.pct
rename to vcl/qa/cppunit/graphicfilter/data/pict/pass/tdf92789.pct
diff --git a/filter/qa/cppunit/filters-pict-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx
similarity index 83%
rename from filter/qa/cppunit/filters-pict-test.cxx
rename to vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx
index b4f0432441db..a24f2d324d97 100644
--- a/filter/qa/cppunit/filters-pict-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-pict-test.cxx
@@ -16,14 +16,7 @@
 #include <vcl/graph.hxx>
 #include <vcl/metaactiontypes.hxx>
 
-#include "../../source/graphicfilter/ipict/ipict.hxx"
-
-extern "C"
-{
-    SAL_DLLPUBLIC_EXPORT bool SAL_CALL
-        iptGraphicImport(SvStream & rStream, Graphic & rGraphic,
-        FilterConfigItem*);
-}
+#include <filter/PictReader.hxx>
 
 using namespace ::com::sun::star;
 
@@ -43,7 +36,7 @@ public:
 
     OUString pictURL()
     {
-        return m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/pict/");
+        return m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/pict/");
     }
 
     /**
@@ -65,20 +58,21 @@ bool PictFilterTest::load(const OUString &,
 {
     SvFileStream aFileStream(rURL, StreamMode::READ);
     Graphic aGraphic;
-    return iptGraphicImport(aFileStream, aGraphic, nullptr);
+    return ImportPictGraphic(aFileStream, aGraphic);
 }
 
 void PictFilterTest::testCVEs()
 {
-    testDir(OUString(),
-        pictURL());
+#ifndef DISABLE_CVE_TESTS
+    testDir(OUString(), pictURL());
+#endif
 }
 
 void PictFilterTest::testDontClipTooMuch()
 {
     SvFileStream aFileStream(pictURL() + "clipping-problem.pct", StreamMode::READ);
     GDIMetaFile aGDIMetaFile;
-    pict::ReadPictFile(aFileStream, aGDIMetaFile);
+    ReadPictFile(aFileStream, aGDIMetaFile);
 
     MetafileXmlDump dumper;
     dumper.filterAllActionTypes();
@@ -95,6 +89,4 @@ void PictFilterTest::testDontClipTooMuch()
 
 CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
 
-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 05ba4eeefe8e..6f9dd9bc13f6 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -43,7 +43,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, nullptr
+    IMP_TGA, IMP_PICT, nullptr
 };
 
 const char* FilterConfigCache::FilterConfigCacheEntry::InternalVectorFilterNameList[] =
@@ -232,8 +232,7 @@ const char* FilterConfigCache::InternalFilterListForSvxLight[] =
     "met","1","ime",
     "png","1","SVIPNG",
     "png","2","SVEPNG",
-    "pct","1","ipt",
-    "pct","2","ept",
+    "pct","1","SVPICT",
     "pcd","1","icd",
     "psd","1","ipd",
     "pcx","1","ipx",
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 3546539b8787..210742388bd7 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -50,6 +50,7 @@
 #include <filter/TiffReader.hxx>
 #include <filter/TiffWriter.hxx>
 #include <filter/TgaReader.hxx>
+#include <filter/PictReader.hxx>
 #include <osl/module.hxx>
 #include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/awt/Size.hpp>
@@ -646,7 +647,6 @@ extern "C" bool imeGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterCo
 extern "C" bool ipbGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
 extern "C" bool ipdGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
 extern "C" bool ipsGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
-extern "C" bool iptGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
 extern "C" bool ipxGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
 extern "C" bool iraGraphicImport( SvStream& rStream, Graphic& rGraphic, FilterConfigItem* pConfigItem );
 
@@ -669,8 +669,6 @@ PFilterCall ImpFilterLibCacheEntry::GetImportFunction()
             mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("ipdGraphicImport"));
         else if (maFormatName == "ips")
             mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("ipsGraphicImport"));
-        else if (maFormatName == "ipt")
-            mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("iptGraphicImport"));
         else if (maFormatName == "ipx")
             mpfnImport = reinterpret_cast<PFilterCall>(maLibrary.getFunctionSymbol("ipxGraphicImport"));
         else if (maFormatName == "ira")
@@ -688,8 +686,6 @@ PFilterCall ImpFilterLibCacheEntry::GetImportFunction()
             mpfnImport = ipdGraphicImport;
         else if (maFormatName ==  "ips")
             mpfnImport = ipsGraphicImport;
-        else if (maFormatName ==  "ipt")
-            mpfnImport = iptGraphicImport;
         else if (maFormatName ==  "ipx")
             mpfnImport = ipxGraphicImport;
         else if (maFormatName ==  "ira")
@@ -1328,6 +1324,10 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size
         {
             eLinkType = GfxLinkType::NativeTif;
         }
+        else if (aFilterName == IMP_PICT)
+        {
+            eLinkType = GfxLinkType::NativePct;
+        }
         else
         {
             nStatus = ERRCODE_GRFILTER_FILTERERROR;
@@ -1363,8 +1363,6 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 size
 
                 if( aShortName.startsWith(MET_SHORTNAME))
                     eLinkType = GfxLinkType::NativeMet;
-                else if( aShortName.startsWith(PCT_SHORTNAME))
-                    eLinkType = GfxLinkType::NativePct;
             }
         }
     }
@@ -1426,7 +1424,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"ime", u"ipb", u"ipd", u"ips", u"ipt", u"ipx", u"ira",
+        u"icd", u"idx", u"ime", u"ipb", u"ipd", u"ips", u"ipx", u"ira",
     };
 
     // Load library for each filter.
@@ -1718,6 +1716,17 @@ ErrCode GraphicFilter::readTGA(SvStream & rStream, Graphic & rGraphic)
         return ERRCODE_GRFILTER_FILTERERROR;
 }
 
+ErrCode GraphicFilter::readPICT(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType)
+{
+    if (ImportPictGraphic(rStream, rGraphic))
+    {
+        rLinkType = GfxLinkType::NativePct;
+        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*/,
@@ -1835,6 +1844,10 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
         {
             nStatus = readTGA(rIStream, rGraphic);
         }
+        else if (aFilterName.equalsIgnoreAsciiCase(IMP_PICT))
+        {
+            nStatus = readPICT(rIStream, rGraphic, eLinkType);
+        }
         else
             nStatus = ERRCODE_GRFILTER_FILTERERROR;
     }
@@ -1880,12 +1893,8 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPath,
                     // try to set link type if format matches
                     if( nFormat != GRFILTER_FORMAT_DONTKNOW )
                     {
-                        if( aShortName.startsWith( TIF_SHORTNAME ) )
-                            eLinkType = GfxLinkType::NativeTif;
-                        else if( aShortName.startsWith( MET_SHORTNAME ) )
+                        if( aShortName.startsWith( MET_SHORTNAME ) )
                             eLinkType = GfxLinkType::NativeMet;
-                        else if( aShortName.startsWith( PCT_SHORTNAME ) )
-                            eLinkType = GfxLinkType::NativePct;
                     }
                 }
             }
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/vcl/source/filter/ipict/ipict.cxx
similarity index 99%
rename from filter/source/graphicfilter/ipict/ipict.cxx
rename to vcl/source/filter/ipict/ipict.cxx
index 16b5c3f6be6e..6bfb7617545c 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/vcl/source/filter/ipict/ipict.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <filter/PictReader.hxx>
 #include <string.h>
 #include <osl/thread.h>
 #include <sal/log.hxx>
@@ -28,8 +29,6 @@
 #include <tools/stream.hxx>
 #include <vcl/virdev.hxx>
 #include <math.h>
-
-#include "ipict.hxx"
 #include "shape.hxx"
 #include <memory>
 
@@ -1989,25 +1988,20 @@ void PictReader::ReadPict( SvStream & rStreamPict, GDIMetaFile & rGDIMetaFile )
     }
 }
 
-namespace pict {
-
 void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile)
 {
     PictReader aPictReader;
     aPictReader.ReadPict(rStreamPict, rGDIMetaFile);
 }
 
-}
-
 //================== GraphicImport - the exported function ================
 
-extern "C" SAL_DLLPUBLIC_EXPORT bool
-iptGraphicImport( SvStream& rIStm, Graphic & rGraphic, FilterConfigItem* )
+bool ImportPictGraphic( SvStream& rIStm, Graphic & rGraphic)
 {
     GDIMetaFile aMTF;
     bool        bRet = false;
 
-    pict::ReadPictFile( rIStm, aMTF );
+    ReadPictFile(rIStm, aMTF);
 
     if ( !rIStm.GetError() )
     {
diff --git a/filter/source/graphicfilter/ipict/shape.cxx b/vcl/source/filter/ipict/shape.cxx
similarity index 100%
rename from filter/source/graphicfilter/ipict/shape.cxx
rename to vcl/source/filter/ipict/shape.cxx
diff --git a/filter/source/graphicfilter/ipict/shape.hxx b/vcl/source/filter/ipict/shape.hxx
similarity index 100%
rename from filter/source/graphicfilter/ipict/shape.hxx
rename to vcl/source/filter/ipict/shape.hxx
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index f2e0d51b0c74..443456299434 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -44,6 +44,7 @@
 #include <fltcall.hxx>
 #include <filter/TiffReader.hxx>
 #include <filter/TgaReader.hxx>
+#include <filter/PictReader.hxx>
 #include <osl/file.hxx>
 #include <osl/module.hxx>
 #include <tools/stream.hxx>
@@ -250,18 +251,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         }
         else if (strcmp(argv[2], "pct") == 0)
         {
-            static PFilterCall pfnImport(nullptr);
-            if (!pfnImport)
-            {
-                osl::Module aLibrary;
-                aLibrary.loadRelative(&thisModule, "libgielo.so");
-                pfnImport = reinterpret_cast<PFilterCall>(
-                    aLibrary.getFunctionSymbol("iptGraphicImport"));
-                aLibrary.release();
-            }
             Graphic aGraphic;
             SvFileStream aFileStream(out, StreamMode::READ);
-            ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr));
+            ret = static_cast<int>(ImportPictGraphic(aFileStream, aGraphic));
         }
         else if (strcmp(argv[2], "pcx") == 0)
         {
diff --git a/vcl/workben/pctfuzzer.cxx b/vcl/workben/pctfuzzer.cxx
index a916920c4b9f..db1ad0c90c30 100644
--- a/vcl/workben/pctfuzzer.cxx
+++ b/vcl/workben/pctfuzzer.cxx
@@ -10,6 +10,7 @@
 #include <tools/stream.hxx>
 #include <vcl/FilterConfigItem.hxx>
 #include "commonfuzzer.hxx"
+#include <filter/PictReader.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 iptGraphicImport(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)iptGraphicImport(aStream, aGraphic, nullptr);
+    (void)ImportPictGraphic(aStream, aGraphic);
     return 0;
 }
 


More information about the Libreoffice-commits mailing list