[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 9800 commits - accessibility/inc accessibility/Library_acc.mk accessibility/source android/Bootstrap android/default-document android/Makefile android/source animations/Library_animcore.mk animations/source apple_remote/source avmedia/inc avmedia/Library_avmediagst.mk avmedia/Library_avmediagtk.mk avmedia/Library_avmediaMacAVF.mk avmedia/Library_avmedia.mk avmedia/Library_avmediawin.mk avmedia/Module_avmedia.mk avmedia/source basctl/inc basctl/IwyuFilter_basctl.yaml basctl/Library_basctl.mk basctl/source basctl/uiconfig basegfx/CppunitTest_basegfx.mk basegfx/Library_basegfx.mk basegfx/source basegfx/test basic/CppunitTest_basic_macros.mk basic/inc basic/IwyuFilter_basic.yaml basic/Library_sb.mk basic/qa basic/source binaryurp/Library_binaryurp.mk binaryurp/qa binaryurp/source bin/check-elf-dynamic-objects bin/check-missing-export-asserts.py bin/check-missing-unittests.py bin/compare-crashreport-stats.py bin/find-can-be-private-s ymbols.classes.results bin/find-can-be-private-symbols.functions.results bin/find-can-be-private-symbols.py bin/find-undocumented-classes bin/find-unneeded-includes bin/find-unused-defines.py bin/fixincludeguards.sh bin/flat-odf-cleanup.py bin/gbuild-to-ide bin/gen-boost-headers bin/gen-iwyu-dummy-lib bin/get-bugzilla-attachments-by-mimetype bin/gla11y bin/list-dispatch-commands.py bin/lo-all-static-libs bin/merge-app-bundles bin/module-deps.pl bin/moveglobalheaders.sh bin/oss-fuzz-build.sh bin/oss-fuzz-setup.sh bin/sanitize-excludelist.txt bin/sanitize-image-links bin/symstore.sh bin/ui-rules-enforcer.py bin/ui-translatable.sh bin/update bin/update_pch bin/update_pch_autotune.sh bin/update_pch_bisect bridges/Library_cpp_uno.mk bridges/Module_bridges.mk bridges/source canvas/Executable_canvasdemo.mk canvas/inc canvas/IwyuFilter_canvas.yaml canvas/Library_cairocanvas.mk canvas/Library_canvasfactory.mk canvas/Library_directx9canvas.mk canvas/Library_gdipluscanvas.mk canvas/Library_ogl canvas.mk canvas/Library_simplecanvas.mk canvas/Library_vclcanvas.mk canvas/Module_canvas.mk canvas/qa canvas/source canvas/workben chart2/CppunitTest_chart2_dump.mk chart2/CppunitTest_chart2_geometry.mk chart2/CppunitTest_chart2_pivot_chart_test.mk chart2/CppunitTest_chart2_trendcalculators.mk chart2/CppunitTest_chart2_xshape.mk chart2/export_setup.mk chart2/import_setup.mk chart2/inc chart2/IwyuFilter_chart2.yaml chart2/Library_chartcontroller.mk chart2/Library_chartcore.mk chart2/qa chart2/source chart2/uiconfig cli_ure/source codemaker/source comphelper/CppunitTest_comphelper_test.mk comphelper/Library_comphelper.mk comphelper/qa comphelper/source compilerplugins/clang compilerplugins/LICENSE.TXT compilerplugins/README.md config_host/config_box2d.h.in config_host/config_clang.h.in config_host/config_eot.h.in config_host/config_features.h.in config_host/config_fonts.h.in config_host/config_global.h.in config_host/config_gpgme.h.in config_host/config_libcxx.h.in config_host/config _options.h.in config_host/config_poppler.h.in config_host/config_skia.h.in config_host/config_validation.h.in config_host/config_vclplug.h.in config_host/config_wasm_strip.h.in config_host.mk.in configmgr/IwyuFilter_configmgr.yaml configmgr/Library_configmgr.mk configmgr/source configure.ac connectivity/CppunitTest_connectivity_sharedresources.mk connectivity/inc connectivity/IwyuFilter_connectivity.yaml connectivity/Library_ado.mk connectivity/Library_calc.mk connectivity/Library_dbase.mk connectivity/Library_dbpool2.mk connectivity/Library_dbtools.mk connectivity/Library_evoab.mk connectivity/Library_firebird_sdbc.mk connectivity/Library_flat.mk connectivity/Library_hsqldb.mk connectivity/Library_jdbc.mk connectivity/Library_macab1.mk connectivity/Library_mozbootstrap.mk connectivity/Library_mysqlc.mk connectivity/Library_mysql_jdbc.mk connectivity/Library_odbc.mk connectivity/Library_postgresql-sdbc-impl.mk connectivity/Library_postgresql-sdbc.mk connectivity/Library_sdbc2.mk con nectivity/Library_writer.mk connectivity/qa connectivity/Rdb_postgresql-sdbc.mk connectivity/registry connectivity/source cppcanvas/Library_mtfrenderer.mk cppcanvas/qa cppcanvas/source cppuhelper/Library_cppuhelper.mk cppuhelper/qa cppuhelper/source cppu/Library_cppu.mk cppu/Library_purpenvhelper.mk cppu/qa cppu/source cpputools/Module_cpputools.mk cpputools/Package_uno_sh.mk cpputools/scripts cpputools/source cui/inc cui/IwyuFilter_cui.yaml cui/Library_cui.mk cui/Module_cui.mk cui/qa cui/source cui/uiconfig cui/UIConfig_cui.mk cui/UITest_cui_tabpages.mk cui/util dbaccess/CppunitTest_dbaccess_dialog_save.mk dbaccess/CppunitTest_dbaccess_empty_stdlib_save.mk dbaccess/CppunitTest_dbaccess_hsqlbinary_import.mk dbaccess/CppunitTest_dbaccess_hsqldb_test.mk dbaccess/CppunitTest_dbaccess_hsqlschema_import.mk dbaccess/CppunitTest_dbaccess_macros_test.mk dbaccess/CppunitTest_dbaccess_nolib_save.mk dbaccess/CppunitTest_dbaccess_RowSetClones.mk dbaccess/CppunitTest_dbaccess_tdf119625.mk dbacce ss/CppunitTest_dbaccess_tdf126268.mk dbaccess/inc dbaccess/IwyuFilter_dbaccess.yaml dbaccess/Library_dba.mk dbaccess/Library_dbaxml.mk dbaccess/Library_dbu.mk dbaccess/Library_sdbt.mk dbaccess/Module_dbaccess.mk dbaccess/qa dbaccess/source dbaccess/uiconfig desktop/CppunitTest_desktop_app.mk desktop/CppunitTest_desktop_lib.mk desktop/CustomTarget_soffice.mk desktop/Executable_oosplash.mk desktop/Executable_soffice_bin.mk desktop/Extension_test-crashextension.mk desktop/inc desktop/Jar_passive_java.mk desktop/Library_crashextension.mk desktop/Library_crashreport.mk desktop/Library_deploymentgui.mk desktop/Library_deployment.mk desktop/Library_migrationoo2.mk desktop/Library_migrationoo3.mk desktop/Library_offacc.mk desktop/Library_passive_native.mk desktop/Library_sofficeapp.mk desktop/Library_spl.mk desktop/Module_desktop.mk desktop/Package_scripts.mk desktop/Pyuno_passive_python.mk desktop/qa desktop/Rdb_crashextension.mk desktop/Rdb_passive_generic.mk desktop/Rdb_passive_platform. mk desktop/README.md desktop/source desktop/test desktop/uiconfig desktop/unx dictionaries distro-configs/Jenkins distro-configs/LibreOfficeCoverity.conf distro-configs/LibreOfficeFlatpak.conf distro-configs/LibreOfficeLinux.conf distro-configs/LibreOfficeOnline.conf distro-configs/LibreOfficeOpenBSD.conf distro-configs/LibreOfficeOssFuzz.conf distro-configs/LibreOfficeVanillaMacAppStore.conf distro-configs/LibreOfficeWASM32.conf distro-configs/LibreOfficeWin32.conf distro-configs/LibreOfficeWin64.conf distro-configs/LibreOfficeWinArm64.conf download.lst drawinglayer/CppunitTest_drawinglayer_border.mk drawinglayer/CppunitTest_drawinglayer_processors.mk drawinglayer/inc drawinglayer/Library_drawinglayercore.mk drawinglayer/Library_drawinglayer.mk drawinglayer/Module_drawinglayer.mk drawinglayer/qa drawinglayer/README.md drawinglayer/source editeng/inc editeng/IwyuFilter_editeng.yaml editeng/Library_editeng.mk editeng/qa editeng/source embeddedobj/Library_embobj.mk embeddedobj/Library _emboleobj.mk embeddedobj/qa embeddedobj/source embedserv/Library_emser.mk embedserv/source emfio/CppunitTest_emfio_emf.mk emfio/CppunitTest_emfio_wmf.mk emfio/inc emfio/Library_emfio.mk emfio/qa emfio/README.md emfio/source eventattacher/Library_evtatt.mk eventattacher/README.md eventattacher/source extensions/CppunitTest_extensions_bibliography.mk extensions/inc extensions/IwyuFilter_extensions.yaml extensions/Library_abp.mk extensions/Library_bib.mk extensions/Library_dbp.mk extensions/Library_ldapbe2.mk extensions/Library_log.mk extensions/Library_oleautobridge.mk extensions/Library_pcr.mk extensions/Library_scn.mk extensions/Library_updatecheckui.mk extensions/Library_updatefeed.mk extensions/Library_updchk.mk extensions/Library_WinUserInfoBe.mk extensions/Module_extensions.mk extensions/qa extensions/source extensions/uiconfig external/apr external/boost external/box2d external/breakpad external/cairo external/clew external/clucene external/coinmp external/cppunit external/ct2 n external/cuckoo external/curl external/dragonbox external/epoxy external/expat external/firebird external/fontconfig external/freetype external/glm external/gpgmepp external/harfbuzz external/hsqldb external/hunspell external/hyphen external/icu external/languagetool external/lcms2 external/libabw external/libassuan external/libatomic_ops external/libcdr external/libcmis external/libebook external/libepubgen external/libetonyek external/libexttextcat external/libffi external/libfreehand external/libgpg-error external/libjpeg-turbo external/liblangtag external/libmspub external/libmwaw external/libnumbertext external/libodfgen external/liborcus external/libpagemaker external/libqxp external/librevenge external/libstaroffice external/libvisio external/libwebp external/libwpd external/libwpg external/libwps external/libxml2 external/libxslt external/libzmf external/lpsolve external/mdds external/Module_external.mk external/mythes external/neon external/nss external/openldap external/ openssl external/pdfium external/poppler external/postgresql external/python3 external/redland external/rhino external/serf external/skia external/xmlsec external/zlib external/zxing extras/CustomTarget_autocorr.mk extras/CustomTarget_autotextshare.mk extras/CustomTarget_autotextuser.mk extras/CustomTarget_tpldraw.mk extras/CustomTarget_tplofficorr.mk extras/CustomTarget_tploffimisc.mk extras/CustomTarget_tplpersonal.mk extras/CustomTarget_tplpresnt.mk extras/CustomTarget_tpl_styles.mk extras/Module_extras.mk extras/README.md extras/source filter/Configuration_filter.mk filter/CppunitTest_filter_pdfimporter_test.mk filter/CppunitTest_filter_pdf.mk filter/CppunitTest_filter_textfilterdetect.mk filter/inc filter/Library_filterconfig.mk filter/Library_graphicfilter.mk filter/Library_icg.mk filter/Library_msfilter.mk filter/Library_odfflatxml.mk filter/Library_pdffilter.mk filter/Library_pdfimporter.mk filter/Library_storagefd.mk filter/Library_svgfilter.mk filter/Library_t602filter.mk filter/Library_textfd.mk filter/Library_xmlfa.mk filter/Library_xmlfd.mk filter/Library_xsltdlg.mk filter/Library_xsltfilter.mk filter/Module_filter.mk filter/qa filter/source filter/uiconfig forms/inc forms/IwyuFilter_forms.yaml forms/Library_frm.mk forms/source formula/inc formula/Library_for.mk formula/source fpicker/inc fpicker/Library_fps_aqua.mk fpicker/Library_fps.mk fpicker/Library_fps_office.mk fpicker/source fpicker/uiconfig framework/inc framework/Library_fwk.mk framework/qa framework/source framework/uiconfig framework/util g .github/lockdown.yml .github/workflows .gitignore hardened_runtime.xcent.in helpcompiler/Module_helpcompiler.mk helpcompiler/source helpcontent2 hwpfilter/Library_hwp.mk hwpfilter/qa hwpfilter/source i18nlangtag/CppunitTest_i18nlangtag_test_languagetag.mk i18nlangtag/qa i18nlangtag/source i18npool/CppunitTest_i18npool_breakiterator.mk i18npool/CppunitTest_i18npool_calendar.mk i18npool/CppunitTest_i18npool_characterclassification.mk i18npool/CppunitT est_i18npool_ordinalsuffix.mk i18npool/CppunitTest_i18npool_test_breakiterator.mk i18npool/CppunitTest_i18npool_test_characterclassification.mk i18npool/CppunitTest_i18npool_test_ordinalsuffix.mk i18npool/CppunitTest_i18npool_test_textsearch.mk i18npool/CppunitTest_i18npool_textsearch.mk i18npool/CustomTarget_breakiterator.mk i18npool/CustomTarget_collator.mk i18npool/CustomTarget_localedata.mk i18npool/inc i18npool/Library_collator_data.mk i18npool/Library_dict_ja.mk i18npool/Library_dict_zh.mk i18npool/Library_i18npool.mk i18npool/Library_i18nsearch.mk i18npool/Library_index_data.mk i18npool/Library_localedata_en.mk i18npool/Library_localedata_es.mk i18npool/Library_localedata_euro.mk i18npool/Library_localedata_others.mk i18npool/Library_textconv_dict.mk i18npool/Module_i18npool.mk i18npool/qa i18npool/Rdb_saxparser.mk i18npool/source i18npool/util i18nutil/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_dark_svg icon-themes/breeze_svg icon-themes/colibre ico n-themes/colibre_dark icon-themes/colibre_dark_svg icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg icon-themes/karasa_jaga icon-themes/karasa_jaga_svg icon-themes/README.md icon-themes/sifr icon-themes/sifr_dark icon-themes/sifr_dark_svg icon-themes/sifr_svg icon-themes/sukapura icon-themes/sukapura_svg idlc/Executable_idlc.mk idlc/inc idlc/source idl/inc idl/IwyuFilter_idl.yaml idl/source include/avmedia include/basegfx include/basic include/canvas include/com include/comphelper include/connectivity include/cppu include/cppuhelper include/cui include/dbaccess include/drawinglayer include/editeng include/embeddedobj include/filter include/formula include/fpicker include/framework include/i18nlangtag include/i18nutil include/IwyuFilter_include.yaml include/jvmaccess include/LibreOfficeKit include/linguistic include/o3tl include/oox include/osl include/package include/registry include/rtl include/sal include/sax include/sfx2 include/svl include/svtools includ e/svx include/systools include/test include/toolkit include/tools include/ucbhelper include/uno include/unoidl include/unotest include/unotools include/vbahelper include/vcl include/xmloff include/xmlreader include/xmlscript install_deps.sh instsetoo_native/CustomTarget_install.mk instsetoo_native/CustomTarget_setup.mk instsetoo_native/inc_ooohelppack instsetoo_native/inc_openoffice instsetoo_native/inc_sdkoo io/Library_io.mk io/source javaunohelper/Library_juhx.mk javaunohelper/source jurt/Library_jpipe.mk jurt/source jvmaccess/source jvmaccess/workbench jvmfwk/distributions jvmfwk/inc jvmfwk/Library_jvmfwk.mk jvmfwk/Package_rcfiles.mk jvmfwk/plugins jvmfwk/source l10ntools/inc l10ntools/IwyuFilter_l10ntools.yaml l10ntools/source librelogo/CustomTarget_librelogo.mk librelogo/Package_librelogo_properties.mk librelogo/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Executable_tilebench.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficek it.mk libreofficekit/qa libreofficekit/source lingucomponent/IwyuFilter_lingucomponent.yaml lingucomponent/Library_guesslang.mk lingucomponent/Library_hyphen.mk lingucomponent/Library_lnth.mk lingucomponent/Library_MacOSXSpell.mk lingucomponent/Library_numbertext.mk lingucomponent/Library_spell.mk lingucomponent/Module_lingucomponent.mk lingucomponent/source linguistic/IwyuFilter_linguistic.yaml linguistic/Library_lng.mk linguistic/source logerrit lotuswordpro/inc lotuswordpro/Library_lwpft.mk lotuswordpro/qa lotuswordpro/source lo.xcent m4/libgcrypt.m4 m4/libo_enable_vclplug.m4 m4/libo_externals.m4 Makefile.fetch Makefile.gbuild Makefile.in nlpsolver/src nlpsolver/ThirdParty o3tl/CppunitTest_o3tl_tests.mk o3tl/IwyuFilter_o3tl.yaml o3tl/qa odk/CppunitTest_odk_checkapi.mk odk/CustomTarget_build-examples.mk odk/CustomTarget_check.mk odk/docs odk/examples odk/index.html odk/index_online.html odk/Package_examples.mk odk/Package_share_readme.mk odk/settings odk/source odk/util offapi/com offapi/type_reference offapi/UnoApi_offapi.mk offapi/util officecfg/CustomTarget_registry.mk officecfg/README.md officecfg/registry onlineupdate/source oovbaapi/ooo oox/CppunitTest_oox_drawingml.mk oox/CppunitTest_oox_export.mk oox/CppunitTest_oox_shape.mk oox/CppunitTest_oox_tokenmap.mk oox/inc oox/IwyuFilter_oox.yaml oox/Library_oox.mk oox/qa oox/README.md oox/source opencl/inc opencl/opencltest opencl/source osx/soffice.xcodeproj package/inc package/IwyuFilter_package.yaml package/Library_package2.mk package/Library_xstor.mk package/qa package/source pch/inc postprocess/CustomTarget_components.mk postprocess/CustomTarget_images.mk postprocess/CustomTarget_registry.mk postprocess/Module_postprocess.mk postprocess/qa postprocess/Rdb_services.mk pyuno/IwyuFilter_pyuno.yaml pyuno/Library_pythonloader.mk pyuno/qa pyuno/Rdb_pyuno.mk pyuno/source qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/runner qadevOOo/tests readlicense_oo/docs readlicense_oo/license README.md README.wasm reg istry/CustomTarget_regcompare_test.mk registry/Module_registry.mk registry/source registry/test registry/tools remotebridges/Library_uuresolver.mk remotebridges/source reportbuilder/Jar_reportbuilder.mk reportdesign/inc reportdesign/Library_rpt.mk reportdesign/Library_rptui.mk reportdesign/Library_rptxml.mk reportdesign/source reportdesign/uiconfig RepositoryExternal.mk RepositoryFixes.mk Repository.mk RepositoryModule_host.mk ridljar/com sal/cppunittester sal/CppunitTest_sal_osl.mk sal/CppunitTest_sal_rtl.mk salhelper/Library_salhelper.mk salhelper/qa salhelper/source sal/inc sal/Library_sal.mk sal/Library_sal_textenc.mk sal/Module_sal.mk sal/osl sal/qa sal/rtl sal/textenc sal/util sax/Library_expwrap.mk sax/qa sax/source scaddins/inc scaddins/Library_analysis.mk scaddins/Library_date.mk scaddins/Library_pricing.mk scaddins/source sccomp/CppunitTest_sccomp_swarmsolvertest.mk sccomp/inc sccomp/Library_solver.mk sccomp/Module_sccomp.mk sccomp/qa sccomp/source sc/CppunitTest_sc_addin_ functions_test.mk sc/CppunitTest_sc_anchor_test.mk sc/CppunitTest_sc_array_functions_test.mk sc/CppunitTest_sc_bugfix_test.mk sc/CppunitTest_sc_cache_test.mk sc/CppunitTest_sc_chart2dataprovider.mk sc/CppunitTest_sc_chart_regression_test.mk sc/CppunitTest_sc_cond_format_merge.mk sc/CppunitTest_sc_copypaste.mk sc/CppunitTest_sc_database_functions_test.mk sc/CppunitTest_sc_datapilotitemobj.mk sc/CppunitTest_sc_datapilottablesobj.mk sc/CppunitTest_sc_dataprovider.mk sc/CppunitTest_sc_datatransformation.mk sc/CppunitTest_sc_datetime_functions_test.mk sc/CppunitTest_sc_filters_test.mk sc/CppunitTest_sc_financial_functions_test.mk sc/CppunitTest_sc_functions_test_old.mk sc/CppunitTest_sc_html_export_test.mk sc/CppunitTest_sc_information_functions_test.mk sc/CppunitTest_sc_jumbosheets_test.mk sc/CppunitTest_sc_logical_functions_test.mk sc/CppunitTest_sc_macros_test.mk sc/CppunitTest_sc_mark_test.mk sc/CppunitTest_sc_mathematical_functions_test.mk sc/CppunitTest_sc_namedrangeobj.mk sc/Cppun itTest_sc_new_cond_format_api.mk sc/CppunitTest_sc_opencl_test.mk sc/CppunitTest_sc_parallelism.mk sc/CppunitTest_sc_pdf_export.mk sc/CppunitTest_sc_perfobj.mk sc/CppunitTest_sc_pivottable_filters_test.mk sc/CppunitTest_sc_rangelst_test.mk sc/CppunitTest_sc_range_test.mk sc/CppunitTest_sc_sparkline_test.mk sc/CppunitTest_sc_spreadsheet_functions_test.mk sc/CppunitTest_sc_statistical_functions_test.mk sc/CppunitTest_sc_subsequent_export-test2.mk sc/CppunitTest_sc_subsequent_export_test2.mk sc/CppunitTest_sc_subsequent_export-test.mk sc/CppunitTest_sc_subsequent_export_test.mk sc/CppunitTest_sc_subsequent_filters-test2.mk sc/CppunitTest_sc_subsequent_filters_test2.mk sc/CppunitTest_sc_subsequent_filters-test.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/CppunitTest_sc_tablecolumnsobj.mk sc/CppunitTest_sc_tablerowsobj.mk sc/CppunitTest_sc_tablesheetobj.mk sc/CppunitTest_sc_text_functions_test.mk sc/CppunitTest_sc_tiledrendering.mk schema/libreoffice sc/inc sc/IwyuFilter_sc.yaml sc /Library_scd.mk sc/Library_scfilt.mk sc/Library_sc.mk sc/Library_scui.mk sc/Library_vbaobj.mk sc/Module_sc.mk scp2/AutoInstall.mk scp2/InstallModule_extensions.mk scp2/source sc/qa scripting/examples scripting/Format_java_code.sh scripting/Jar_ScriptFramework.mk scripting/Jar_ScriptProviderForBeanShell.mk scripting/Jar_ScriptProviderForJava.mk scripting/Jar_ScriptProviderForJavaScript.mk scripting/java scripting/Library_basprov.mk scripting/Library_dlgprov.mk scripting/Library_protocolhandler.mk scripting/Library_scriptframe.mk scripting/Library_stringresource.mk scripting/Library_vbaevents.mk scripting/Module_scripting.mk scripting/Package_ScriptsBeanShell.mk scripting/Pyuno_mailmerge.mk scripting/Rdb_scriptproviderforbeanshell.mk scripting/Rdb_scriptproviderforjavascript.mk scripting/source sc/sdi sc/source sc/TODO.performance sc/ucalc_setup.mk sc/uiconfig sc/UIConfig_scalc.mk sc/UITest_autofilter2.mk sc/UITest_chart2.mk sc/UITest_external_links.mk sd/CppunitTest_sd_export_tests-o oxml3.mk sd/CppunitTest_sd_import_tests2.mk sd/CppunitTest_sd_import_tests.mk sd/CppunitTest_sd_import_tests-smartart.mk sd/CppunitTest_sd_import_tests_smartart.mk sd/CppunitTest_sd_png_export_tests.mk sd/CppunitTest_sd_uimpress.mk sdext/Library_pdfimport.mk sdext/Library_PresentationMinimizer.mk sdext/Library_PresenterScreen.mk sdext/source sd/import_setup.mk sd/inc sd/IwyuFilter_sd.yaml sd/Library_sdd.mk sd/Library_sdfilt.mk sd/Library_sd.mk sd/Library_sdui.mk sd/Module_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sd/UIConfig_simpress.mk sd/UITest_impress_tests.mk sd/UITest_sd_findReplace.mk setup_native/Package_packinfo.mk setup_native/scripts setup_native/source sfx2/inc sfx2/IwyuFilter_sfx2.yaml sfx2/Library_sfx.mk sfx2/qa sfx2/sdi sfx2/source sfx2/uiconfig sfx2/util shell/inc shell/Library_cmdmail.mk shell/Library_desktopbe.mk shell/Library_jumplist.mk shell/Library_kf5be.mk shell/Library_localebe.mk shell/Library_losessioninstall.mk shell/Library_macbe.mk shell/Library_smplmail.m k shell/Library_syssh.mk shell/Library_wininetbe.mk shell/Module_shell.mk shell/qa shell/source slideshow/inc slideshow/IwyuFilter_slideshow.yaml slideshow/Library_OGLTrans.mk slideshow/Library_slideshow.mk slideshow/source slideshow/test smoketest/Jar_smoketest.mk smoketest/Module_smoketest.mk smoketest/smoketest.cxx solenv/bin solenv/clang-format solenv/CompilerTest_compilerplugins_clang-c++03.mk solenv/CompilerTest_compilerplugins_clang.mk solenv/Executable_gbuildtojson.mk solenv/Executable_gcc-wrapper.mk solenv/Executable_g++-wrapper.mk solenv/Executable_lockfile.mk solenv/flatpak-manifest.in solenv/gbuild solenv/gbuildtojson solenv/gcc-wrappers solenv/gdb solenv/inc solenv/lockfile solenv/Module_solenv.mk solenv/README.md solenv/sanitizers solenv/StaticLibrary_wrapper.mk solenv/vs soltools/mkdepend sot/inc sot/IwyuFilter_sot.yaml sot/Library_sot.mk sot/source starmath/CppunitTest_starmath_qa_cppunit.mk starmath/inc starmath/IwyuFilter_starmath.yaml starmath/Library_smd.mk starm ath/Library_sm.mk starmath/qa starmath/source starmath/uiconfig starmath/UIConfig_smath.mk starmath/util static/CustomTarget_components.mk static/CustomTarget_emscripten_fs_image.mk static/CustomTarget_wasm-qt5-mandelbrot_moc.mk static/emscripten static/Executable_wasm-qt5-mandelbrot.mk static/Library_components.mk static/Makefile static/Module_static.mk static/README.md static/README.wasm.md static/source stoc/Library_bootstrap.mk stoc/Library_introspection.mk stoc/Library_invocadapt.mk stoc/Library_invocation.mk stoc/Library_javaloader.mk stoc/Library_javavm.mk stoc/Library_namingservice.mk stoc/Library_proxyfac.mk stoc/Library_reflection.mk stoc/Library_stocservices.mk stoc/source stoc/test store/source svgio/CppunitTest_svgio.mk svgio/CppunitTest_svgio_read.mk svgio/CppunitTest_svgio_tools.mk svgio/inc svgio/Library_svgio.mk svgio/qa svgio/README.md svgio/source svl/IwyuFilter_svl.yaml svl/Library_fsstorage.mk svl/Library_passwordcontainer.mk svl/Library_svl.mk svl/qa svl/source svl/unx svtools/inc svtools/IwyuFilter_svtools.yaml svtools/Library_svt.mk svtools/qa svtools/source svtools/uiconfig svx/CppunitTest_svx_core.mk svx/CppunitTest_svx_removewhichrange.mk svx/CppunitTest_svx_styles.mk svx/CppunitTest_svx_unit.mk svx/Executable_gengal.mk svx/inc svx/IwyuFilter_svx.yaml svx/Library_svxcore.mk svx/Library_svx.mk svx/Library_textconversiondlgs.mk svx/Module_svx.mk svx/qa svx/README.md svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk svx/util sw/CppunitTest_sw_apitests.mk sw/CppunitTest_sw_core_attr.mk sw/CppunitTest_sw_core_edit.mk sw/CppunitTest_sw_core_layout.mk sw/CppunitTest_sw_core_text.mk sw/CppunitTest_sw_core_txtnode.mk sw/CppunitTest_sw_core_view.mk sw/CppunitTest_sw_htmlexport.mk sw/CppunitTest_sw_macros_test.mk sw/CppunitTest_sw_ooxmlexport17.mk sw/CppunitTest_sw_uibase_shells.mk sw/CppunitTest_sw_uibase_wrtsh.mk sw/CppunitTest_sw_uiwriter4.mk sw/CppunitTest_sw_uiwriter5.mk sw/CppunitTest_sw_uiwriter6.mk sw/CppunitTest_sw_uiwriter7.mk sw/Cp punitTest_sw_uwriter.mk swext/mediawiki sw/inc sw/IwyuFilter_sw.yaml sw/layoutwriter_setup.mk sw/Library_msword.mk sw/Library_swd.mk sw/Library_sw.mk sw/Library_swui.mk sw/Library_vbaswobj.mk sw/Module_sw.mk sw/qa sw/rtfexport_setup.mk sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk sw/UITest_sw_fieldDialog.mk sw/UITest_sw_findSimilarity.mk sw/UITest_sw_uibase_shells.mk sw/uiwriter_setup.mk sw/util sysui/desktop test/Library_test.mk test/qa test/signing-keys test/source testtools/com testtools/IwyuFilter_testtools.yaml testtools/Jar_testComponent.mk testtools/Library_bridgetest.mk testtools/Library_constructors.mk testtools/Library_cppobj.mk testtools/Rdb_uno_services.mk testtools/source test/user-template toolkit/inc toolkit/IwyuFilter_toolkit.yaml toolkit/Library_tk.mk toolkit/qa toolkit/source tools/CppunitTest_tools_test.mk tools/inc tools/IwyuFilter_tools.yaml tools/Library_tl.mk tools/qa tools/source translations tsan-suppress.txt ucb/CppunitTest_ucb_webdav_core.mk ucb/Cpp unitTest_ucb_webdav_local_neon.mk ucb/CppunitTest_ucb_webdav_neon_opts.mk ucb/CppunitTest_ucb_webdav_propfindcache.mk ucb/CppunitTest_ucb_webdav_res_access.mk ucbhelper/IwyuFilter_ucbhelper.yaml ucbhelper/source ucb/IwyuFilter_ucb.yaml ucb/Library_cached1.mk ucb/Library_srtrs1.mk ucb/Library_ucb1.mk ucb/Library_ucpcmis1.mk ucb/Library_ucpdav1.mk ucb/Library_ucpexpand1.mk ucb/Library_ucpext.mk ucb/Library_ucpfile1.mk ucb/Library_ucpftp1.mk ucb/Library_ucpgio1.mk ucb/Library_ucphier1.mk ucb/Library_ucpimage.mk ucb/Library_ucppkg1.mk ucb/Library_ucptdoc1.mk ucb/Module_ucb.mk ucb/qa ucb/README.md ucb/source ucb/test udkapi/com uitest/demo_ui uitest/impress_tests uitest/libreoffice uitest/math_tests uitest/test_main.py uitest/ui_logger_dsl uitest/uitest uitest/UITest_math_demo.mk UnoControls/inc UnoControls/IwyuFilter_UnoControls.yaml UnoControls/Library_ctl.mk UnoControls/source unodevtools/inc unodevtools/IwyuFilter_unodevtools.yaml unodevtools/source unoidl/CustomTarget_unoidl-check_t est.mk unoidl/Library_unoidl.mk unoidl/Module_unoidl.mk unoidl/qa unoidl/README.md unoidl/source unotest/Library_unotest.mk unotest/source unotools/IwyuFilter_unotools.yaml unotools/Library_utl.mk unotools/qa unotools/source unoxml/inc unoxml/Library_unordf.mk unoxml/Library_unoxml.mk unoxml/qa unoxml/source ure/Module_ure.mk ure/Package_install.mk ure/Package_ure_install.mk ure/Rdb_ure.mk ure/source uui/inc uui/Library_uui.mk uui/source vbahelper/inc vbahelper/Library_msforms.mk vbahelper/Library_vbahelper.mk vbahelper/source vcl/android vcl/backendtest vcl/commonfuzzer.mk vcl/CppunitTest_vcl_animation.mk vcl/CppunitTest_vcl_backend_test.mk vcl/CppunitTest_vcl_bitmap_test.mk vcl/CppunitTest_vcl_drawmode.mk vcl/CppunitTest_vcl_filter_ipdf.mk vcl/CppunitTest_vcl_filters_test.mk vcl/CppunitTest_vcl_font.mk vcl/CppunitTest_vcl_gradient.mk vcl/CppunitTest_vcl_svm_test.mk vcl/CppunitTest_vcl_text.mk vcl/CustomTarget_qt5_moc.mk vcl/CustomTarget_qt6_moc.mk vcl/Executable_602fuzzer.mk vcl/E xecutable_benchmark.mk vcl/Executable_bmpfuzzer.mk vcl/Executable_cgmfuzzer.mk vcl/Executable_dbffuzzer.mk vcl/Executable_diffuzzer.mk vcl/Executable_docxfuzzer.mk vcl/Executable_dxffuzzer.mk vcl/Executable_epsfuzzer.mk vcl/Executable_fftester.mk vcl/Executable_fodpfuzzer.mk vcl/Executable_fodsfuzzer.mk vcl/Executable_fodtfuzzer.mk vcl/Executable_giffuzzer.mk vcl/Executable_htmlfuzzer.mk vcl/Executable_hwpfuzzer.mk vcl/Executable_icontest.mk vcl/Executable_jpgfuzzer.mk vcl/Executable_listfonts.mk vcl/Executable_lo_kde5filepicker.mk vcl/Executable_lwpfuzzer.mk vcl/Executable_metfuzzer.mk vcl/Executable_minvcl.mk vcl/Executable_mmlfuzzer.mk vcl/Executable_mtfdemo.mk vcl/Executable_mtpfuzzer.mk vcl/Executable_olefuzzer.mk vcl/Executable_pcdfuzzer.mk vcl/Executable_pctfuzzer.mk vcl/Executable_pcxfuzzer.mk vcl/Executable_pngfuzzer.mk vcl/Executable_ppmfuzzer.mk vcl/Executable_pptfuzzer.mk vcl/Executable_pptxfuzzer.mk vcl/Executable_psdfuzzer.mk vcl/Executable_qpwfuzzer.mk vcl/Executable_ rasfuzzer.mk vcl/Executable_rtffuzzer.mk vcl/Executable_scrtffuzzer.mk vcl/Executable_sftfuzzer.mk vcl/Executable_slkfuzzer.mk vcl/Executable_svdemo.mk vcl/Executable_svmfuzzer.mk vcl/Executable_svpclient.mk vcl/Executable_svptest.mk vcl/Executable_tgafuzzer.mk vcl/Executable_tiffuzzer.mk vcl/Executable_ui-previewer.mk vcl/Executable_vcldemo.mk vcl/Executable_visualbackendtest.mk vcl/Executable_webpfuzzer.mk vcl/Executable_wksfuzzer.mk vcl/Executable_wmffuzzer.mk vcl/Executable_ww2fuzzer.mk vcl/Executable_ww6fuzzer.mk vcl/Executable_ww8fuzzer.mk vcl/Executable_xbmfuzzer.mk vcl/Executable_xlsfuzzer.mk vcl/Executable_xlsxfuzzer.mk vcl/Executable_xpmfuzzer.mk vcl/headless vcl/inc vcl/ios vcl/jsdialog vcl/Library_desktop_detector.mk vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_gtk3_kde5.mk vcl/Library_vclplug_gtk3.mk vcl/Library_vclplug_gtk4.mk vcl/Library_vclplug_kf5.mk vcl/Library_vclplug_osx.mk vcl/Library_vclplug_qt5.mk vcl/Library_vclplug_qt6.mk vcl/Library_vcl plug_win.mk vcl/Module_vcl.mk vcl/null vcl/osx vcl/qa vcl/qt5 vcl/qt6 vcl/quartz vcl/README.GDIMetaFile vcl/README.GDIMetaFile.md vcl/README.lifecycle vcl/README.lifecycle.md vcl/README.md vcl/README.scheduler vcl/README.scheduler.md vcl/README.vars vcl/README.vars.md vcl/skia vcl/source vcl/StaticLibrary_fuzzerstubs.mk vcl/StaticLibrary_glxtest.mk vcl/uiconfig vcl/UIConfig_vcl.mk vcl/unx vcl/vcl.android.component vcl/vcl.common.component vcl/vcl.common.component.android vcl/vcl.common.component.headless vcl/vcl.common.component.ios vcl/vcl.common.component.macosx vcl/vcl.common.component.unx vcl/vcl.common.component.windows vcl/vcl.headless.component vcl/vcl.ios.component vcl/vcl.macosx.component vcl/vcl.unx.component vcl/vcl.windows.component vcl/win vcl/workben .vscode/vs-code-template.code-workspace.in wasm-qt/CustomTarget_wasm-qt5-mandelbrot_moc.mk wasm-qt/Executable_wasm-qt5-mandelbrot.mk wasm-qt/Makefile wasm-qt/Module_wasm-qt.mk wasm-qt/README wasm-qt/source winaccessibility /inc winaccessibility/Library_uacccom.mk winaccessibility/Library_winaccessibility.mk winaccessibility/source wizards/com wizards/CustomTarget_wizards.mk wizards/Jar_form.mk wizards/Jar_query.mk wizards/Jar_report.mk wizards/Jar_table.mk wizards/Module_wizards.mk wizards/Package_scriptforge.mk wizards/Package_sfdocuments.mk wizards/Package_sfwidgets.mk wizards/Package_wizards_properties.mk wizards/Pyuno_agenda.mk wizards/Pyuno_fax.mk wizards/Pyuno_letter.mk wizards/source writerfilter/CppunitTest_writerfilter_dmapper.mk writerfilter/CppunitTest_writerfilter_rtftok.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/qa writerfilter/source writerperfect/inc writerperfect/Library_wpftcalc.mk writerperfect/Library_wpftdraw.mk writerperfect/Library_wpftimpress.mk writerperfect/Library_wpftwriter.mk writerperfect/Module_writerperfect.mk writerperfect/qa writerperfect/source xmerge/Jar_XMergeBridge.mk xmlhelp/Library_ucpchelp1.mk xmlhelp/source xmloff/CppunitTest_xmloff_d raw.mk xmloff/CppunitTest_xmloff_text.mk xmloff/inc xmloff/Library_xof.mk xmloff/Library_xo.mk xmloff/qa xmloff/source xmloff/util xmlreader/Library_xmlreader.mk xmlscript/Library_xmlscript.mk xmlscript/qa xmlscript/source xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk xmlsecurity/CppunitTest_xmlsecurity_signing.mk xmlsecurity/inc xmlsecurity/Library_xmlsecurity.mk xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/Module_xmlsecurity.mk xmlsecurity/qa xmlsecurity/README.md xmlsecurity/source xmlsecurity/uiconfig xmlsecurity/util xmlsecurity/workben

Wed, 11 May 2022 01:37:06 -0700

Rebased ref, commits from common ancestor:
commit 15afec15f6cecc97399a41a10d63553b313a8ddc
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 10 15:45:13 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:12 2022 +0900

    vcl: add more methods to the PDFium
    
    Change-Id: I74ef0f713125c7069620d1abc9534a636c1707d9

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index c5f1766f60c0..46988cf3c946 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -111,6 +111,13 @@ public:
     virtual PDFSegmentType getType() const = 0;
 };
 
+struct PDFImageMetadata
+{
+    sal_uInt32 mnWidth;
+    sal_uInt32 mnHeight;
+    sal_uInt32 mnBitsPerPixel;
+};
+
 class VCL_DLLPUBLIC PDFiumPageObject
 {
 public:
@@ -127,15 +134,20 @@ public:
     virtual double getFontSize() = 0;
     virtual OUString getFontName() = 0;
     virtual PDFTextRenderMode getTextRenderMode() = 0;
+    virtual bool hasTransparency() = 0;
     virtual Color getFillColor() = 0;
     virtual Color getStrokeColor() = 0;
     virtual double getStrokeWidth() = 0;
     // Path
     virtual int getPathSegmentCount() = 0;
     virtual std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) = 0;
+    virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
+    // Image
     virtual Size getImageSize(PDFiumPage& rPage) = 0;
+    virtual PDFImageMetadata getImageMetadata(PDFiumPage& rPage) = 0;
+
     virtual std::unique_ptr<PDFiumBitmap> getImageBitmap() = 0;
-    virtual bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) = 0;
+    virtual bool getDecodedImageData(std::vector<sal_uInt8>& rData) = 0;
 };
 
 class VCL_DLLPUBLIC PDFiumSearchHandle
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index d02e2a0bab49..b38506245758 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -255,15 +255,19 @@ public:
     double getFontSize() override;
     OUString getFontName() override;
     PDFTextRenderMode getTextRenderMode() override;
+    bool hasTransparency() override;
     Color getFillColor() override;
     Color getStrokeColor() override;
     double getStrokeWidth() override;
     // Path
     int getPathSegmentCount() override;
     std::unique_ptr<PDFiumPathSegment> getPathSegment(int index) override;
+    bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) override;
+    // Image
     Size getImageSize(PDFiumPage& rPage) override;
+    PDFImageMetadata getImageMetadata(PDFiumPage& rPage) override;
     std::unique_ptr<PDFiumBitmap> getImageBitmap() override;
-    bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) override;
+    bool getDecodedImageData(std::vector<sal_uInt8>& rData) override;
 };
 
 class PDFiumSearchHandleImpl final : public PDFiumSearchHandle
@@ -842,6 +846,8 @@ Color PDFiumPageObjectImpl::getFillColor()
     return aColor;
 }
 
+bool PDFiumPageObjectImpl::hasTransparency() { return 
FPDFPageObj_HasTransparency(mpPageObject); }
+
 Color PDFiumPageObjectImpl::getStrokeColor()
 {
     Color aColor = COL_TRANSPARENT;
@@ -881,6 +887,28 @@ Size PDFiumPageObjectImpl::getImageSize(PDFiumPage& rPage)
     return Size(aMeta.width, aMeta.height);
 }
 
+PDFImageMetadata PDFiumPageObjectImpl::getImageMetadata(PDFiumPage& rPage)
+{
+    FPDF_IMAGEOBJ_METADATA aMeta;
+    auto& rPageImpl = static_cast<PDFiumPageImpl&>(rPage);
+    FPDFImageObj_GetImageMetadata(mpPageObject, rPageImpl.getPointer(), 
&aMeta);
+    return { aMeta.width, aMeta.height, aMeta.bits_per_pixel };
+}
+
+bool PDFiumPageObjectImpl::getDecodedImageData(std::vector<sal_uInt8>& rData)
+{
+    unsigned long nLength = FPDFImageObj_GetImageDataDecoded(mpPageObject, 
nullptr, 0);
+    if (nLength > 0)
+    {
+        rData.resize(nLength);
+        unsigned long nReadLength
+            = FPDFImageObj_GetImageDataDecoded(mpPageObject, rData.data(), 
nLength);
+        if (nReadLength == nLength)
+            return true;
+    }
+    return false;
+}
+
 std::unique_ptr<PDFiumBitmap> PDFiumPageObjectImpl::getImageBitmap()
 {
     std::unique_ptr<PDFiumBitmap> pPDFiumBitmap;
commit d843c0040fd9b4d75b8acb31f1634058b24e8c33
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 3 16:42:22 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:12 2022 +0900

    Add PDF importer to read a PDF into drawinglayer primitives
    
    Change-Id: I8d2e28a39515dfef8a1b4c6b06df095dd3a4eaec

diff --git a/Repository.mk b/Repository.mk
index 360f558c9be5..42dabcd39418 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -440,6 +440,7 @@ $(eval $(call 
gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
        passwordcontainer \
        pcr \
        pdffilter \
+       pdfimporter \
        $(call gb_Helper_optional,SCRIPTING,protocolhandler) \
        sax \
        sb \
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 886ffbf7fdd3..565d22fb5b05 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -489,6 +489,13 @@ void Primitive2dXmlDump::dump(
     aWriter.endDocument();
 
     pStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+    std::size_t nSize = pStream->remainingSize();
+    std::unique_ptr<sal_uInt8[]> pBuffer(new sal_uInt8[nSize + 1]);
+    pStream->ReadBytes(pBuffer.get(), nSize);
+    pBuffer[nSize] = 0;
+
+    printf ("%s\n", pBuffer.get());
 }
 
 namespace
diff --git a/filter/CppunitTest_filter_pdfimporter_test.mk 
b/filter/CppunitTest_filter_pdfimporter_test.mk
new file mode 100644
index 000000000000..3b17dcdcb43f
--- /dev/null
+++ b/filter/CppunitTest_filter_pdfimporter_test.mk
@@ -0,0 +1,48 @@
+# -*- 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_pdfimporter_test))
+
+$(eval $(call gb_CppunitTest_use_externals,filter_pdfimporter_test,\
+       boost_headers \
+       libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,filter_pdfimporter_test, \
+    filter/qa/cppunit/PdfImporterTest \
+))
+
+$(eval $(call gb_CppunitTest_use_library_objects,filter_pdfimporter_test,\
+    pdfimporter \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,filter_pdfimporter_test, \
+    basegfx \
+    drawinglayer \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    test \
+    unotest \
+    utl \
+    tl \
+    vcl \
+    tk \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,filter_pdfimporter_test))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_ure,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_vcl,filter_pdfimporter_test))
+$(eval $(call gb_CppunitTest_use_rdb,filter_pdfimporter_test,services))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Library_pdfimporter.mk b/filter/Library_pdfimporter.mk
new file mode 100644
index 000000000000..93a567cbc247
--- /dev/null
+++ b/filter/Library_pdfimporter.mk
@@ -0,0 +1,35 @@
+# -*- 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_Library_Library,pdfimporter))
+
+$(eval $(call gb_Library_set_include,pdfimporter,\
+       -I$(SRCDIR)/filter/inc \
+       $$(INCLUDE) \
+))
+
+$(eval $(call gb_Library_use_external,pdfimporter,boost_headers))
+
+$(eval $(call gb_Library_add_exception_objects,pdfimporter,\
+       filter/source/pdfimporter/PDFImporter \
+))
+
+$(eval $(call gb_Library_use_libraries,pdfimporter,\
+       drawinglayer \
+       basegfx \
+       vcl \
+       tl \
+       sal \
+       cppu \
+       tk \
+))
+
+$(eval $(call gb_Library_use_sdk_api,pdfimporter))
+
+# vim: set noet sw=4 ts=4:
diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk
index c28c72705cec..e8ef1649c876 100644
--- a/filter/Module_filter.mk
+++ b/filter/Module_filter.mk
@@ -26,6 +26,7 @@ $(eval $(call gb_Module_add_targets,filter,\
        Library_msfilter \
        Library_odfflatxml \
        Library_pdffilter \
+       Library_pdfimporter \
        Library_storagefd \
        Library_svgfilter \
        Library_graphicfilter \
@@ -49,6 +50,7 @@ $(eval $(call gb_Module_add_check_targets,filter,\
     CppunitTest_filter_xslt \
     CppunitTest_filter_priority \
     CppunitTest_filter_msfilter \
+    CppunitTest_filter_pdfimporter_test \
     CppunitTest_filter_textfilterdetect \
     CppunitTest_filter_pdf \
 ))
diff --git a/filter/qa/cppunit/PdfImporterTest.cxx 
b/filter/qa/cppunit/PdfImporterTest.cxx
new file mode 100644
index 000000000000..ee57b9bdbc67
--- /dev/null
+++ b/filter/qa/cppunit/PdfImporterTest.cxx
@@ -0,0 +1,173 @@
+/* -*- 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/.
+ */
+
+#include <sal/config.h>
+#include <sal/types.h>
+#include <test/bootstrapfixture.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <filter/pdfimporter/PDFImporter.hxx>
+#include <vcl/BinaryDataContainer.hxx>
+#include <tools/stream.hxx>
+#include <drawinglayer/converters.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/tools/primitive2dxmldump.hxx>
+
+#include <tools/stream.hxx>
+#include <vcl/pngwrite.hxx>
+
+class PDFImporterTest : public test::BootstrapFixture, public XmlTestTools
+{
+    OUString getFullUrl(std::u16string_view sFileName)
+    {
+        return m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/") + 
sFileName;
+    }
+
+    void testPath();
+    void testImage();
+    void testText();
+
+    CPPUNIT_TEST_SUITE(PDFImporterTest);
+    //CPPUNIT_TEST(testPath);
+    //CPPUNIT_TEST(testImage);
+    CPPUNIT_TEST(testText);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void PDFImporterTest::testPath()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Rect.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+void PDFImporterTest::testImage()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Image.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+void PDFImporterTest::testText()
+{
+    SvFileStream aFileStream(getFullUrl(u"/PdfTest-Text.pdf"), 
StreamMode::READ);
+    const sal_uInt64 nStreamLength = aFileStream.TellEnd();
+    auto rData = std::make_unique<std::vector<sal_uInt8>>(nStreamLength);
+    aFileStream.ReadBytes(rData->data(), rData->size());
+    BinaryDataContainer aDataContainer(std::move(rData));
+    PDFImporter aImporter(aDataContainer);
+
+    drawinglayer::primitive2d::Primitive2DContainer aContainer;
+    aImporter.importPage(0, aContainer);
+
+    drawinglayer::geometry::ViewInformation2D rViewInformation2D;
+
+    auto aRange = aContainer.getB2DRange(rViewInformation2D);
+
+    BitmapEx aBitmapEx
+        = drawinglayer::convertToBitmapEx(aContainer, rViewInformation2D, 
2000, 2000, 10000 * 1000);
+
+    SvFileStream aNew("~/xxxxxxx.png", StreamMode::WRITE | StreamMode::TRUNC);
+    vcl::PNGWriter aPNGWriter(aBitmapEx);
+    aPNGWriter.Write(aNew);
+
+    drawinglayer::Primitive2dXmlDump aDumper;
+    aDumper.dump(aContainer, OUString());
+    xmlDocUniquePtr pDocument = aDumper.dumpAndParse(aContainer);
+    CPPUNIT_ASSERT(pDocument);
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/transform/unifiedtransparence",
+                "transparence", "0.498039215686275");
+
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinX());
+    CPPUNIT_ASSERT_EQUAL(-0.5, aRange.getMinY());
+    CPPUNIT_ASSERT_EQUAL(612.5, aRange.getMaxX());
+    CPPUNIT_ASSERT_EQUAL(792.5, aRange.getMaxY());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(1000), aBitmapEx.GetSizePixel().Height());
+
+    CPPUNIT_ASSERT(false);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(PDFImporterTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/qa/cppunit/data/PdfTest-Image.pdf 
b/filter/qa/cppunit/data/PdfTest-Image.pdf
new file mode 100644
index 000000000000..394ee272f3d4
Binary files /dev/null and b/filter/qa/cppunit/data/PdfTest-Image.pdf differ
diff --git a/filter/qa/cppunit/data/PdfTest-Rect.pdf 
b/filter/qa/cppunit/data/PdfTest-Rect.pdf
new file mode 100644
index 000000000000..7115df65176f
--- /dev/null
+++ b/filter/qa/cppunit/data/PdfTest-Rect.pdf
@@ -0,0 +1,134 @@
+%PDF-1.6
+%äüöß
+2 0 obj
+<</Length 3 0 R/Filter/FlateDecode>>
+stream
+x����JA��y��{�&ٙ�Y(=�UQ�z�   ڪl.H_����"����!��%��x�7$�@R03��el;��=<-�
���#��O��
X#7��Ly�3��y9����j���6H��զ
+1���%K�̤0��hL:R,�SsSH�8S����BJ�duL�bg��|�Օs �4�����h����m�}E�� 
�ƅ��*�H���l��'���8a���M9��4S���Q���X8wY
+endstream
+endobj
+
+3 0 obj
+241
+endobj
+
+8 0 obj
+<<
+>>
+endobj
+
+9 0 obj
+<</Font 8 0 R
+/ProcSet[/PDF/Text]
+>>
+endobj
+
+1 0 obj
+<</Type/Page/Parent 7 0 R/Resources 9 0 R/MediaBox[0 0 612 792]/StructParents 0
+/Group<</S/Transparency/CS/DeviceRGB/I true>>/Contents 2 0 R>>
+endobj
+
+10 0 obj
+<</Count 1/First 11 0 R/Last 11 0 R
+>>
+endobj
+
+11 0 obj
+<</Count 0/Title<FEFF005000610067006500200031>
+/Dest[1 0 R/XYZ 0 792 0]/Parent 10 0 R>>
+endobj
+
+4 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[0 ]
+>>
+endobj
+
+5 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[1 ]
+>>
+endobj
+
+6 0 obj
+<</Type/StructElem
+/S/Figure
+/P 12 0 R
+/Pg 1 0 R
+/K[2 ]
+>>
+endobj
+
+12 0 obj
+<</Type/StructTreeRoot
+/ParentTree 13 0 R
+/K[4 0 R 5 0 R 6 0 R ]
+>>
+endobj
+
+13 0 obj
+<</Nums[
+0 [ 4 0 R 5 0 R 6 0 R ]
+]>>
+endobj
+
+7 0 obj
+<</Type/Pages
+/Resources 9 0 R
+/MediaBox[ 0 0 612 792 ]
+/Kids[ 1 0 R ]
+/Count 1>>
+endobj
+
+14 0 obj
+<</Type/Catalog/Pages 7 0 R
+/OpenAction[1 0 R /XYZ null null 0]
+/ViewerPreferences<</DisplayDocTitle true
+>>
+/Outlines 10 0 R
+/StructTreeRoot 12 0 R
+/MarkInfo<</Marked true>>
+>>
+endobj
+
+15 0 obj
+<</Title<FEFF004D007900540065006D0070006C006100740065>
+/Creator<FEFF0044007200610077>
+/Producer<FEFF004C0069006200720065004F0066006600690063006500200037002E0030>
+/CreationDate(D:20210505091047+09'00')>>
+endobj
+
+xref
+0 16
+0000000000 65535 f 
+0000000426 00000 n 
+0000000019 00000 n 
+0000000331 00000 n 
+0000000746 00000 n 
+0000000821 00000 n 
+0000000896 00000 n 
+0000001110 00000 n 
+0000000351 00000 n 
+0000000373 00000 n 
+0000000585 00000 n 
+0000000641 00000 n 
+0000000971 00000 n 
+0000001056 00000 n 
+0000001208 00000 n 
+0000001403 00000 n 
+trailer
+<</Size 16/Root 14 0 R
+/Info 15 0 R
+/ID [ <3F7788F2D0928B3B95B0CDBBD9EAC1B8>
+<3F7788F2D0928B3B95B0CDBBD9EAC1B8> ]
+/DocChecksum /F2715E25D79DC609834CA579FA23A5BA
+>>
+startxref
+1623
+%%EOF
diff --git a/filter/qa/cppunit/data/PdfTest-Text.pdf 
b/filter/qa/cppunit/data/PdfTest-Text.pdf
new file mode 100644
index 000000000000..c449bf559228
Binary files /dev/null and b/filter/qa/cppunit/data/PdfTest-Text.pdf differ
diff --git a/filter/source/pdfimporter/PDFImporter.cxx 
b/filter/source/pdfimporter/PDFImporter.cxx
new file mode 100644
index 000000000000..b4b37aea7128
--- /dev/null
+++ b/filter/source/pdfimporter/PDFImporter.cxx
@@ -0,0 +1,384 @@
+/* -*- 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/.
+ *
+ */
+
+#include <filter/pdfimporter/PDFImporter.hxx>
+
+#include <sal/log.hxx>
+#include <tools/UnitConversion.hxx>
+#include <tools/color.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapTools.hxx>
+
+#include <cmath>
+
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+#include <drawinglayer/attribute/lineattribute.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
+#include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx>
+#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+
+PDFImporter::PDFImporter(BinaryDataContainer& rDataContainer)
+    : mpPDFium(vcl::pdf::PDFiumLibrary::get())
+{
+    auto* pData = rDataContainer.getData();
+    sal_Int32 nSize = rDataContainer.getSize();
+
+    mpPdfDocument = mpPDFium->openDocument(pData, nSize);
+}
+
+namespace
+{
+void setupPage(drawinglayer::primitive2d::Primitive2DContainer& rContainer,
+               basegfx::B2DSize const& rPageSize)
+{
+    basegfx::B2DRange aPageRange(0.0, 0.0, rPageSize.getX(), rPageSize.getY());
+
+    printf("Page Size %.2fpt %.2fpt\n", rPageSize.getX(), rPageSize.getY());
+
+    const auto aPolygon = basegfx::utils::createPolygonFromRect(aPageRange);
+
+    const drawinglayer::primitive2d::Primitive2DReference xPage(
+        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPolygon,
+                                                                  
basegfx::BColor(0.0, 0.0, 0.0)));
+    const drawinglayer::primitive2d::Primitive2DReference xHidden(
+        new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(
+            drawinglayer::primitive2d::Primitive2DContainer{ xPage }));
+
+    rContainer.push_back(xHidden);
+}
+
+double sqrt2(double a, double b) { return sqrt(a * a + b * b); }
+
+} // end anonymous namespace
+
+bool PDFImporter::importPage(int nPageIndex,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rContainer)
+{
+    if (!mpPdfDocument)
+        return false;
+
+    drawinglayer::primitive2d::Primitive2DContainer aContent;
+
+    const int nPageCount = mpPdfDocument->getPageCount();
+    if (!(nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount))
+        return false;
+
+    mpPdfPage = mpPdfDocument->openPage(nPageIndex);
+    if (!mpPdfPage)
+        return false;
+
+    basegfx::B2DSize aPageSize = mpPdfDocument->getPageSize(nPageIndex);
+
+    setupPage(aContent, aPageSize);
+
+    // Load the page text to extract it when we get text elements.
+    auto pTextPage = mpPdfPage->getTextPage();
+
+    const int nPageObjectCount = mpPdfPage->getObjectCount();
+
+    for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; 
++nPageObjectIndex)
+    {
+        auto pPageObject = mpPdfPage->getObject(nPageObjectIndex);
+        importPdfObject(pPageObject, pTextPage, nPageObjectIndex, aContent);
+    }
+
+    // point to pixel conversion
+    double dConversionFactor = double(conversionFract(o3tl::Length::pt, 
o3tl::Length::px));
+    const auto aTransform = basegfx::utils::createScaleTranslateB2DHomMatrix(
+        dConversionFactor, -dConversionFactor, 0.0, aPageSize.getY() * 
dConversionFactor);
+
+    const drawinglayer::primitive2d::Primitive2DReference xTransform(
+        new drawinglayer::primitive2d::TransformPrimitive2D(aTransform, 
aContent));
+
+    rContainer.push_back(xTransform);
+
+    return true;
+}
+
+void PDFImporter::importPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                                  std::unique_ptr<vcl::pdf::PDFiumTextPage> 
const& pTextPage,
+                                  int nPageObjectIndex,
+                                  
drawinglayer::primitive2d::Primitive2DContainer& rContent)
+{
+    if (!pPageObject)
+        return;
+
+    const vcl::pdf::PDFPageObjectType ePageObjectType = pPageObject->getType();
+    switch (ePageObjectType)
+    {
+        case vcl::pdf::PDFPageObjectType::Text:
+            printf("pdf::PDFPageObjectType::Text\n");
+            importText(pPageObject, pTextPage, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Path:
+            printf("pdf::PDFPageObjectType::Path\n");
+            importPath(pPageObject, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Image:
+            printf("pdf::PDFPageObjectType::Image\n");
+            importImage(pPageObject, rContent);
+            break;
+        case vcl::pdf::PDFPageObjectType::Shading:
+            printf("pdf::PDFPageObjectType::Shading\n");
+            break;
+        case vcl::pdf::PDFPageObjectType::Form:
+            printf("pdf::PDFPageObjectType::Form\n");
+            break;
+        case vcl::pdf::PDFPageObjectType::Unknown:
+            SAL_WARN("filter", "Unknown PDF page object #" << nPageObjectIndex
+                                                           << " of type: " << 
int(ePageObjectType));
+            break;
+    }
+}
+
+void PDFImporter::importText(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                             std::unique_ptr<vcl::pdf::PDFiumTextPage> const& 
pTextPage,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    basegfx::B2DRectangle aTextRect = pPageObject->getBounds();
+    basegfx::B2DHomMatrix aMatrix = pPageObject->getMatrix();
+
+    OUString sText = pPageObject->getText(pTextPage);
+
+    const double dFontSize = pPageObject->getFontSize();
+    double dFontSizeH = std::fabs(sqrt2(aMatrix.a(), aMatrix.c()) * dFontSize);
+    double dFontSizeV = std::fabs(sqrt2(aMatrix.b(), aMatrix.d()) * dFontSize);
+
+    OUString sFontName = pPageObject->getFontName();
+
+    printf("TEXT: %s\n", sText.toUtf8().getStr());
+
+    Color aTextColor(COL_TRANSPARENT);
+    bool bFill = false;
+    bool bUse = true;
+
+    switch (pPageObject->getTextRenderMode())
+    {
+        case vcl::pdf::PDFTextRenderMode::Fill:
+        case vcl::pdf::PDFTextRenderMode::FillClip:
+        case vcl::pdf::PDFTextRenderMode::FillStroke:
+        case vcl::pdf::PDFTextRenderMode::FillStrokeClip:
+            bFill = true;
+            break;
+        case vcl::pdf::PDFTextRenderMode::Stroke:
+        case vcl::pdf::PDFTextRenderMode::StrokeClip:
+        case vcl::pdf::PDFTextRenderMode::Unknown:
+            break;
+        case vcl::pdf::PDFTextRenderMode::Invisible:
+        case vcl::pdf::PDFTextRenderMode::Clip:
+            bUse = false;
+            break;
+    }
+
+    if (bUse)
+    {
+        Color aColor = bFill ? pPageObject->getFillColor() : 
pPageObject->getStrokeColor();
+        if (aColor != COL_TRANSPARENT)
+        {
+            aTextColor = aColor.GetRGBColor();
+        }
+    }
+}
+
+void PDFImporter::importImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                              drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    std::unique_ptr<vcl::pdf::PDFiumBitmap> pPdfBitmap = 
pPageObject->getImageBitmap();
+    if (!pPdfBitmap)
+    {
+        SAL_WARN("filter", "Failed to get IMAGE");
+        return;
+    }
+
+    const vcl::pdf::PDFBitmapType eFormat = pPdfBitmap->getFormat();
+    if (eFormat == vcl::pdf::PDFBitmapType::Unknown)
+    {
+        SAL_WARN("filter", "Failed to get IMAGE format");
+        return;
+    }
+
+    vcl::pdf::PDFImageMetadata aMetadata = 
pPageObject->getImageMetadata(*mpPdfPage);
+    printf("METADATA %lu %lu %lu\n", aMetadata.mnWidth, aMetadata.mnHeight,
+           aMetadata.mnBitsPerPixel);
+
+    const sal_uInt8* pBuffer = pPdfBitmap->getBuffer();
+    const int nWidth = pPdfBitmap->getWidth();
+    const int nHeight = pPdfBitmap->getHeight();
+    const int nStride = pPdfBitmap->getStride();
+
+    BitmapEx aBitmap;
+
+    printf("hasTransparency %d\n", pPageObject->hasTransparency());
+
+    switch (eFormat)
+    {
+        case vcl::pdf::PDFBitmapType::BGR:
+            printf("vcl::pdf::PDFBitmapType::BGR\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N24_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::BGRx:
+            printf("vcl::pdf::PDFBitmapType::BGRx\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N32_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::BGRA:
+            printf("vcl::pdf::PDFBitmapType::BGRA\n");
+            aBitmap = vcl::bitmap::CreateFromData(pBuffer, nWidth, nHeight, 
nStride,
+                                                  vcl::PixelFormat::N32_BPP);
+            break;
+        case vcl::pdf::PDFBitmapType::Gray:
+            // TODO
+        default:
+            SAL_WARN("filter", "Got IMAGE width: " << nWidth << ", height: " 
<< nHeight
+                                                   << ", stride: " << nStride
+                                                   << ", format: " << 
int(eFormat));
+            break;
+    }
+
+    basegfx::B2DRectangle aBounds = pPageObject->getBounds();
+
+    rRootContainer.push_back(new drawinglayer::primitive2d::BitmapPrimitive2D(
+        VCLUnoHelper::CreateVCLXBitmap(aBitmap), 
basegfx::utils::createScaleTranslateB2DHomMatrix(
+                                                     aBounds.getRange(), 
aBounds.getMinimum())));
+}
+
+void PDFImporter::importPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> 
const& pPageObject,
+                             drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer)
+{
+    drawinglayer::primitive2d::Primitive2DContainer aContent;
+
+    basegfx::B2DHomMatrix aPathMatrix = pPageObject->getMatrix();
+
+    basegfx::B2DPolyPolygon aPolyPolygon;
+    basegfx::B2DPolygon aPolygon;
+    std::vector<basegfx::B2DPoint> aBezier;
+
+    const int nSegments = pPageObject->getPathSegmentCount();
+    for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
+    {
+        auto pPathSegment = pPageObject->getPathSegment(nSegmentIndex);
+        if (!pPathSegment)
+            continue;
+
+        basegfx::B2DPoint aB2DPoint = pPathSegment->getPoint();
+
+        aPolygon.setClosed(pPathSegment->isClosed());
+
+        const vcl::pdf::PDFSegmentType eSegmentType = pPathSegment->getType();
+        switch (eSegmentType)
+        {
+            case vcl::pdf::PDFSegmentType::Lineto:
+            {
+                aPolygon.append(aB2DPoint);
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Bezierto:
+            {
+                aBezier.emplace_back(aB2DPoint.getX(), aB2DPoint.getY());
+                if (aBezier.size() == 3)
+                {
+                    aPolygon.appendBezierSegment(aBezier[0], aBezier[1], 
aBezier[2]);
+                    aBezier.clear();
+                }
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Moveto:
+            {
+                if (aPolygon.count() > 0)
+                {
+                    aPolyPolygon.append(aPolygon);
+                    aPolygon.clear();
+                }
+
+                aPolygon.append(aB2DPoint);
+            }
+            break;
+
+            case vcl::pdf::PDFSegmentType::Unknown:
+            default:
+            {
+                SAL_WARN("filter", "Unknown path segment type in PDF: " << 
int(eSegmentType));
+            }
+            break;
+        }
+    }
+
+    if (aBezier.size() == 3)
+    {
+        aPolygon.appendBezierSegment(aBezier[0], aBezier[1], aBezier[2]);
+        aBezier.clear();
+    }
+
+    if (aPolygon.count() > 0)
+    {
+        aPolyPolygon.append(aPolygon, 1);
+        aPolygon.clear();
+    }
+
+    printf("PolyPoly size %d\n", aPolyPolygon.count());
+    for (auto const& rPoly : aPolyPolygon)
+        printf("Poly size %d\n", rPoly.count());
+
+    double fStrokeWidth = pPageObject->getStrokeWidth();
+    printf("Stroke: %f\n", fStrokeWidth);
+
+    vcl::pdf::PDFFillMode nFillMode = vcl::pdf::PDFFillMode::Alternate;
+    bool bStroke = true;
+
+    if (!pPageObject->getDrawMode(nFillMode, bStroke))
+    {
+        SAL_WARN("filter", "Huh...");
+    }
+
+    Color aFillColor = pPageObject->getFillColor();
+    Color aStokeColor = COL_TRANSPARENT;
+
+    if (bStroke)
+    {
+        aStokeColor = pPageObject->getStrokeColor();
+    }
+
+    if (aStokeColor == COL_TRANSPARENT)
+        aStokeColor = aFillColor;
+
+    if (!bStroke)
+    {
+        const drawinglayer::primitive2d::Primitive2DReference 
xPolyPolygonColorPrimitive(
+            new 
drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(aPolyPolygon,
+                                                                       
aFillColor.getBColor()));
+        aContent.push_back(xPolyPolygonColorPrimitive);
+    }
+
+    drawinglayer::attribute::LineAttribute 
aLineAttribute(aStokeColor.getBColor(), fStrokeWidth);
+    const drawinglayer::primitive2d::Primitive2DReference 
xPolyPolygonStrokePrimitive(
+        new 
drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(aPolyPolygon, 
aLineAttribute));
+    aContent.push_back(xPolyPolygonStrokePrimitive);
+
+    const drawinglayer::primitive2d::Primitive2DReference xTransform(
+        new drawinglayer::primitive2d::TransformPrimitive2D(aPathMatrix, 
aContent));
+    rRootContainer.push_back(xTransform);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/filter/pdfimporter/PDFImporter.hxx 
b/include/filter/pdfimporter/PDFImporter.hxx
new file mode 100644
index 000000000000..01cd94d264c9
--- /dev/null
+++ b/include/filter/pdfimporter/PDFImporter.hxx
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/filter/PDFiumLibrary.hxx>
+#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
+#include <vcl/BinaryDataContainer.hxx>
+
+class PDFImporter
+{
+private:
+    std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
+    std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
+    std::unique_ptr<vcl::pdf::PDFiumPage> mpPdfPage;
+
+    void importPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                         std::unique_ptr<vcl::pdf::PDFiumTextPage> const& 
pTextPage,
+                         int nPageObjectIndex,
+                         drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                    std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
+                    drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                    drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+    void importImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& 
pPageObject,
+                     drawinglayer::primitive2d::Primitive2DContainer& 
rRootContainer);
+
+public:
+    PDFImporter(BinaryDataContainer& rDataContainer);
+
+    bool importPage(int nPageIndex, 
drawinglayer::primitive2d::Primitive2DContainer& rContainer);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0fb19d3217f499af86acdaa244ef73a162a85475
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Mar 18 15:59:20 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:12 2022 +0900

    vcl: bring back RGB565 scanline transformer
    
    While we don't support this as a Bitmap format anymore, we still
    need to transform a buffer that is in RGB565 format in some cases.
    For example backwards compatibility or if a certain bitmap format
    supports such pixel format.
    This change also simplifies some scanline transformers by removing
    code duplication.
    
    Change-Id: I64aa258b8b1fbebf0ed174c0d5fdd2f75f382b28

diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
index c343cf34f61e..dc305937b5fd 100644
--- a/vcl/inc/bitmap/ScanlineTools.hxx
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -16,7 +16,7 @@
 
 namespace vcl::bitmap
 {
-class ScanlineTransformer
+class IScanlineTransformer
 {
 public:
     virtual void startLine(sal_uInt8* pLine) = 0;
@@ -24,127 +24,162 @@ public:
     virtual Color readPixel() = 0;
     virtual void writePixel(Color nColor) = 0;
 
-    virtual ~ScanlineTransformer() = default;
+    virtual ~IScanlineTransformer() = default;
 };
 
-class ScanlineTransformer_ARGB final : public ScanlineTransformer
+class ScanlineTransformer_RGB565 final : public IScanlineTransformer
 {
-private:
-    sal_uInt8* pData;
+protected:
+    sal_uInt16* mpData;
 
 public:
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+    void startLine(sal_uInt8* pLine) override { mpData = 
reinterpret_cast<sal_uInt16*>(pLine); }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel << 2; 
}
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel; }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const Color aColor(ColorTransparency, pData[4], pData[1], pData[2], 
pData[3]);
-        pData += 4;
-        return aColor;
+        sal_uInt8 R = sal_uInt8((*mpData & 0xf800) >> 8);
+        sal_uInt8 G = sal_uInt8((*mpData & 0x07e0) >> 3);
+        sal_uInt8 B = sal_uInt8((*mpData & 0x001f) << 3);
+        mpData++;
+        return Color(R, G, B);
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = 255 - nColor.GetAlpha();
-        *pData++ = nColor.GetRed();
-        *pData++ = nColor.GetGreen();
-        *pData++ = nColor.GetBlue();
+        sal_uInt16 R = (nColor.GetRed() & 0xf8) << 8;
+        sal_uInt16 G = (nColor.GetGreen() & 0xfc) << 3;
+        sal_uInt16 B = (nColor.GetBlue() & 0xf8) >> 3;
+        *mpData++ = R | G | B;
     }
 };
 
-class ScanlineTransformer_BGR final : public ScanlineTransformer
+class ScanlineTransformerBase : public IScanlineTransformer
 {
-private:
-    sal_uInt8* pData;
+protected:
+    sal_uInt8* mpData;
 
 public:
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+    ScanlineTransformerBase()
+        : mpData(nullptr)
+    {
+    }
+
+    void startLine(sal_uInt8* pLine) override { mpData = pLine; }
+};
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += (nPixel << 
1) + nPixel; }
+class ScanlineTransformer_ARGB final : public ScanlineTransformerBase
+{
+public:
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel << 2; }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const Color aColor(pData[2], pData[1], pData[0]);
-        pData += 3;
+        const Color aColor(ColorTransparency, mpData[4], mpData[1], mpData[2], 
mpData[3]);
+        mpData += 4;
         return aColor;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = nColor.GetBlue();
-        *pData++ = nColor.GetGreen();
-        *pData++ = nColor.GetRed();
+        *mpData++ = 255 - nColor.GetAlpha();
+        *mpData++ = nColor.GetRed();
+        *mpData++ = nColor.GetGreen();
+        *mpData++ = nColor.GetBlue();
     }
 };
 
-class ScanlineTransformer_8BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_BGR final : public ScanlineTransformerBase
 {
-private:
-    sal_uInt8* pData;
+public:
+    void skipPixel(sal_uInt32 nPixel) override { mpData += (nPixel << 1) + 
nPixel; }
+
+    Color readPixel() override
+    {
+        const Color aColor(mpData[2], mpData[1], mpData[0]);
+        mpData += 3;
+        return aColor;
+    }
+
+    void writePixel(Color nColor) override
+    {
+        *mpData++ = nColor.GetBlue();
+        *mpData++ = nColor.GetGreen();
+        *mpData++ = nColor.GetRed();
+    }
+};
+
+class ScanlineTransformerPaletteBase : public ScanlineTransformerBase
+{
+protected:
     const BitmapPalette& mrPalette;
 
 public:
-    explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
+    ScanlineTransformerPaletteBase(const BitmapPalette& rPalette)
+        : ScanlineTransformerBase()
         , mrPalette(rPalette)
     {
     }
+};
 
-    virtual void startLine(sal_uInt8* pLine) override { pData = pLine; }
+class ScanlineTransformer_8BitPalette final : public 
ScanlineTransformerPaletteBase
+{
+public:
+    explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
+    {
+    }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel; }
+    void skipPixel(sal_uInt32 nPixel) override { mpData += nPixel; }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const sal_uInt8 nIndex(*pData++);
+        const sal_uInt8 nIndex(*mpData++);
         if (nIndex < mrPalette.GetEntryCount())
             return mrPalette[nIndex];
         else
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
-        *pData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor));
+        *mpData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor));
     }
 };
 
-class ScanlineTransformer_4BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_4BitPalette final : public 
ScanlineTransformerPaletteBase
 {
 private:
-    sal_uInt8* pData;
-    const BitmapPalette& mrPalette;
     sal_uInt32 mnX;
     sal_uInt32 mnShift;
 
 public:
     explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
-        , mrPalette(rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
         , mnX(0)
         , mnShift(0)
     {
     }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override
+    void skipPixel(sal_uInt32 nPixel) override
     {
         mnX += nPixel;
         if (nPixel & 1) // is nPixel an odd number
             mnShift ^= 4;
     }
 
-    virtual void startLine(sal_uInt8* pLine) override
+    void startLine(sal_uInt8* pLine) override
     {
-        pData = pLine;
+        ScanlineTransformerBase::startLine(pLine);
         mnX = 0;
         mnShift = 4;
     }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
         const sal_uInt32 nDataIndex = mnX / 2;
-        const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f);
+        const sal_uInt8 nIndex((mpData[nDataIndex] >> mnShift) & 0x0f);
         mnX++;
         mnShift ^= 4;
 
@@ -154,42 +189,39 @@ public:
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
         const sal_uInt32 nDataIndex = mnX / 2;
         const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor);
-        pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
+        mpData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
         mnX++;
         mnShift ^= 4;
     }
 };
 
-class ScanlineTransformer_1BitPalette final : public ScanlineTransformer
+class ScanlineTransformer_1BitPalette final : public 
ScanlineTransformerPaletteBase
 {
 private:
-    sal_uInt8* pData;
-    const BitmapPalette& mrPalette;
     sal_uInt32 mnX;
 
 public:
     explicit ScanlineTransformer_1BitPalette(const BitmapPalette& rPalette)
-        : pData(nullptr)
-        , mrPalette(rPalette)
+        : ScanlineTransformerPaletteBase(rPalette)
         , mnX(0)
     {
     }
 
-    virtual void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; }
+    void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; }
 
-    virtual void startLine(sal_uInt8* pLine) override
+    void startLine(sal_uInt8* pLine) override
     {
-        pData = pLine;
+        ScanlineTransformerBase::startLine(pLine);
         mnX = 0;
     }
 
-    virtual Color readPixel() override
+    Color readPixel() override
     {
-        const sal_uInt8 nIndex((pData[mnX >> 3] >> (7 - (mnX & 7))) & 1);
+        const sal_uInt8 nIndex((mpData[mnX >> 3] >> (7 - (mnX & 7))) & 1);
         mnX++;
 
         if (nIndex < mrPalette.GetEntryCount())
@@ -198,18 +230,18 @@ public:
             return COL_BLACK;
     }
 
-    virtual void writePixel(Color nColor) override
+    void writePixel(Color nColor) override
     {
         if (mrPalette.GetBestIndex(nColor) & 1)
-            pData[mnX >> 3] |= 1 << (7 - (mnX & 7));
+            mpData[mnX >> 3] |= 1 << (7 - (mnX & 7));
         else
-            pData[mnX >> 3] &= ~(1 << (7 - (mnX & 7)));
+            mpData[mnX >> 3] &= ~(1 << (7 - (mnX & 7)));
         mnX++;
     }
 };
 
-std::unique_ptr<ScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits,
-                                                            const 
BitmapPalette& rPalette)
+std::unique_ptr<IScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits,
+                                                             const 
BitmapPalette& rPalette)
 {
     switch (nBits)
     {
@@ -219,6 +251,8 @@ std::unique_ptr<ScanlineTransformer> 
getScanlineTransformer(sal_uInt16 nBits,
             return std::make_unique<ScanlineTransformer_4BitPalette>(rPalette);
         case 8:
             return std::make_unique<ScanlineTransformer_8BitPalette>(rPalette);
+        case 16:
+            return std::make_unique<ScanlineTransformer_RGB565>();
         case 24:
             return std::make_unique<ScanlineTransformer_BGR>();
         case 32:
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx 
b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index c6751b827ca1..6f497b2b8295 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -19,6 +19,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
 {
     void ScanlineTransformer_32_ARGB();
     void ScanlineTransformer_24_BGR();
+    void ScanlineTransformer_16_RGB565();
     void ScanlineTransformer_8bit_Palette();
     void ScanlineTransformer_4bit_Palette();
     void ScanlineTransformer_1bit_Palette();
@@ -26,6 +27,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
     CPPUNIT_TEST_SUITE(ScanlineToolsTest);
     CPPUNIT_TEST(ScanlineTransformer_32_ARGB);
     CPPUNIT_TEST(ScanlineTransformer_24_BGR);
+    CPPUNIT_TEST(ScanlineTransformer_16_RGB565);
     CPPUNIT_TEST(ScanlineTransformer_8bit_Palette);
     CPPUNIT_TEST(ScanlineTransformer_4bit_Palette);
     CPPUNIT_TEST(ScanlineTransformer_1bit_Palette);
@@ -35,8 +37,7 @@ class ScanlineToolsTest : public CppUnit::TestFixture
 void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
 {
     BitmapPalette aPalette;
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(32, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(32, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5 * 4, 0); // 5 * 4 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -64,8 +65,7 @@ void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
 void ScanlineToolsTest::ScanlineTransformer_24_BGR()
 {
     BitmapPalette aPalette;
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(24, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(24, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5 * 3, 0); // 5 * 3 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -90,6 +90,51 @@ void ScanlineToolsTest::ScanlineTransformer_24_BGR()
     }
 }
 
+void ScanlineToolsTest::ScanlineTransformer_16_RGB565()
+{
+    BitmapPalette aPalette;
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(16, 
aPalette);
+
+    // Test writing - we apply colors which will be written into the scanline
+    // in the R5G6B5 format
+    std::vector<sal_uInt8> aScanLine(5 * 2, 0); // 5 * 2 BytesPerPixel
+    pScanlineTransformer->startLine(aScanLine.data());
+
+    std::vector<Color> aColors{
+        Color(ColorTransparency, 0, 10, 250, 120),   Color(ColorTransparency, 
50, 30, 230, 110),
+        Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 
150, 70, 190, 90),
+        Color(ColorTransparency, 200, 90, 170, 80),
+    };
+
+    for (Color const& aColor : aColors)
+    {
+        pScanlineTransformer->writePixel(aColor);
+    }
+
+    std::vector<sal_uInt8> aExpectedBytes{ 207, 15, 45, 31, 140, 54, 235, 69, 
74, 93 };
+
+    for (size_t i = 0; i < aScanLine.size(); ++i)
+    {
+        CPPUNIT_ASSERT_EQUAL(int(aExpectedBytes[i]), int(aScanLine[i]));
+    }
+
+    // Test reading - we insert a scanline in R5G6B5 format and read
+    // the colors from it
+
+    pScanlineTransformer->startLine(aScanLine.data());
+
+    std::vector<Color> aExpectedColors{
+        Color(8, 248, 120), Color(24, 228, 104), Color(48, 208, 96),
+        Color(64, 188, 88), Color(88, 168, 80),
+    };
+
+    for (size_t i = 0; i < aExpectedColors.size(); ++i)
+    {
+        Color aColor = pScanlineTransformer->readPixel();
+        CPPUNIT_ASSERT_EQUAL(aExpectedColors[i], aColor);
+    }
+}
+
 void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
 {
     std::vector<Color> aColors{
@@ -102,8 +147,7 @@ void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
     for (size_t i = 0; i < aColors.size(); ++i)
         aPalette[i] = aColors[i];
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(8, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(8, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(5, 0); // 5 * 1 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -142,8 +186,7 @@ void ScanlineToolsTest::ScanlineTransformer_4bit_Palette()
         aPalette[i] = aColors[i];
     }
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(4, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(4, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(3, 0); // 6 * 0.5 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
@@ -182,8 +225,7 @@ void ScanlineToolsTest::ScanlineTransformer_1bit_Palette()
     aPalette[0] = Color(10, 250, 120);
     aPalette[1] = Color(110, 150, 70);
 
-    std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
-        = vcl::bitmap::getScanlineTransformer(1, aPalette);
+    auto pScanlineTransformer = vcl::bitmap::getScanlineTransformer(1, 
aPalette);
 
     std::vector<sal_uInt8> aScanLine(2, 0); // 13 * 1/8 BytesPerPixel
     pScanlineTransformer->startLine(aScanLine.data());
commit 308b9d7f045584cacbbd5e864990e9a210a14216
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Mar 7 13:48:39 2021 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:12 2022 +0900

    vcl: add PNG writer based on libpng
    
    Change-Id: I52ffd1b286162ee0dd9f694c4f3210385f71daf8

diff --git a/include/vcl/filter/PngImageWriter.hxx 
b/include/vcl/filter/PngImageWriter.hxx
new file mode 100644
index 000000000000..4f64a028af53
--- /dev/null
+++ b/include/vcl/filter/PngImageWriter.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ *
+ */
+
+#include <vcl/dllapi.h>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <tools/stream.hxx>
+#include <vcl/bitmapex.hxx>
+
+#pragma once
+
+namespace vcl
+{
+class VCL_DLLPUBLIC PngImageWriter
+{
+    SvStream& mrStream;
+    css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator;
+
+    int mnCompressionLevel;
+    bool mbInterlaced;
+
+public:
+    PngImageWriter(SvStream& rStream);
+
+    virtual ~PngImageWriter() {}
+
+    void setParameters(css::uno::Sequence<css::beans::PropertyValue> const& 
rParameters)
+    {
+        for (auto const& rValue : rParameters)
+        {
+            if (rValue.Name == "Compression")
+                rValue.Value >>= mnCompressionLevel;
+            else if (rValue.Name == "Interlaced")
+                rValue.Value >>= mbInterlaced;
+        }
+    }
+    bool write(BitmapEx& rBitmap);
+};
+
+} // namespace vcl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 366e991a2e16..70299a7c5937 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -475,6 +475,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/filter/wmf/wmfexternal \
     vcl/source/filter/wmf/wmfwr \
     vcl/source/filter/png/PngImageReader \
+    vcl/source/filter/png/PngImageWriter \
     vcl/source/filter/png/pngwrite \
     vcl/source/filter/webp/reader \
     vcl/source/filter/webp/writer \
diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx 
b/vcl/qa/cppunit/png/PngFilterTest.cxx
index c167c4c9c636..1c5f29b40abe 100644
--- a/vcl/qa/cppunit/png/PngFilterTest.cxx
+++ b/vcl/qa/cppunit/png/PngFilterTest.cxx
@@ -24,14 +24,20 @@
 #include <test/bootstrapfixture.hxx>
 #include <tools/stream.hxx>
 #include <vcl/filter/PngImageReader.hxx>
+#include <vcl/filter/PngImageWriter.hxx>
 #include <vcl/BitmapReadAccess.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
 #include <vcl/alpha.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <unotools/tempfile.hxx>
 
 using namespace css;
 
 class PngFilterTest : public test::BootstrapFixture
 {
+    // Should keep the temp files (should be false)
+    static constexpr bool bKeepTemp = true;
+
     OUString maDataUrl;
 
     OUString getFullUrl(std::u16string_view sFileName)
@@ -48,10 +54,16 @@ public:
 
     void testPng();
     void testMsGifInPng();
+    void testPngRoundtrip8BitGrey();
+    void testPngRoundtrip24();
+    void testPngRoundtrip32();
 
     CPPUNIT_TEST_SUITE(PngFilterTest);
     CPPUNIT_TEST(testPng);
     CPPUNIT_TEST(testMsGifInPng);
+    CPPUNIT_TEST(testPngRoundtrip8BitGrey);
+    CPPUNIT_TEST(testPngRoundtrip24);
+    CPPUNIT_TEST(testPngRoundtrip32);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -245,6 +257,106 @@ void PngFilterTest::testMsGifInPng()
     CPPUNIT_ASSERT(aGraphic.IsAnimated());
 }
 
+void PngFilterTest::testPngRoundtrip8BitGrey()
+{
+    utl::TempFile aTempFile("testPngRoundtrip8BitGrey");
+    if (!bKeepTemp)
+        aTempFile.EnableKillingFile();
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE);
+        Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
+        {
+            BitmapScopedWriteAccess pWriteAccess(aBitmap);
+            pWriteAccess->Erase(COL_BLACK);
+            for (int i = 0; i < 8; ++i)
+            {
+                for (int j = 0; j < 8; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_GRAY);
+                }
+            }
+            for (int i = 8; i < 16; ++i)
+            {
+                for (int j = 8; j < 16; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTGRAY);
+                }
+            }
+        }
+        BitmapEx aBitmapEx(aBitmap);
+
+        vcl::PngImageWriter aPngWriter(rStream);
+        CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx));
+        aTempFile.CloseStream();
+    }
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::READ);
+
+        vcl::PngImageReader aPngReader(rStream);
+        BitmapEx aBitmapEx;
+        CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx));
+
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width());
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height());
+
+        CPPUNIT_ASSERT_EQUAL(COL_GRAY, aBitmapEx.GetPixelColor(0, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTGRAY, aBitmapEx.GetPixelColor(15, 15));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(15, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(0, 15));
+    }
+}
+
+void PngFilterTest::testPngRoundtrip24()
+{
+    utl::TempFile aTempFile("testPngRoundtrip24");
+    if (!bKeepTemp)
+        aTempFile.EnableKillingFile();
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE);
+        Bitmap aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP);
+        {
+            BitmapScopedWriteAccess pWriteAccess(aBitmap);
+            pWriteAccess->Erase(COL_BLACK);
+            for (int i = 0; i < 8; ++i)
+            {
+                for (int j = 0; j < 8; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTRED);
+                }
+            }
+            for (int i = 8; i < 16; ++i)
+            {
+                for (int j = 8; j < 16; ++j)
+                {
+                    pWriteAccess->SetPixel(i, j, COL_LIGHTBLUE);
+                }
+            }
+        }
+        BitmapEx aBitmapEx(aBitmap);
+
+        vcl::PngImageWriter aPngWriter(rStream);
+        CPPUNIT_ASSERT_EQUAL(true, aPngWriter.write(aBitmapEx));
+    }
+    {
+        SvStream& rStream = *aTempFile.GetStream(StreamMode::READ);
+        rStream.Seek(0);
+
+        vcl::PngImageReader aPngReader(rStream);
+        BitmapEx aBitmapEx;
+        CPPUNIT_ASSERT_EQUAL(true, aPngReader.read(aBitmapEx));
+
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Width());
+        CPPUNIT_ASSERT_EQUAL(16L, aBitmapEx.GetSizePixel().Height());
+
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aBitmapEx.GetPixelColor(0, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, aBitmapEx.GetPixelColor(15, 15));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(15, 0));
+        CPPUNIT_ASSERT_EQUAL(COL_BLACK, aBitmapEx.GetPixelColor(0, 15));
+    }
+}
+
+void PngFilterTest::testPngRoundtrip32() {}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(PngFilterTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
new file mode 100644
index 000000000000..c1e638e0aad0
--- /dev/null
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -0,0 +1,143 @@
+/* -*- 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/.
+ *
+ */
+
+#include <vcl/filter/PngImageWriter.hxx>
+#include <png.h>
+#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/bitmap.hxx>
+
+namespace vcl
+{
+static void lclWriteStream(png_structp pPng, png_bytep pData, png_size_t 
pDataSize)
+{
+    png_voidp pIO = png_get_io_ptr(pPng);
+
+    if (pIO == nullptr)
+        return;
+
+    SvStream* pStream = static_cast<SvStream*>(pIO);
+
+    sal_Size nBytesWritten = pStream->WriteBytes(pData, pDataSize);
+
+    if (nBytesWritten != pDataSize)
+        png_error(pPng, "Write Error");
+}
+
+bool pngWrite(SvStream& rStream, BitmapEx& rBitmapEx, int nCompressionLevel)
+{
+    png_structp pPng = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, 
nullptr, nullptr);
+
+    if (!pPng)
+        return false;
+
+    png_infop pInfo = png_create_info_struct(pPng);
+    if (!pInfo)
+    {
+        png_destroy_write_struct(&pPng, nullptr);
+        return false;
+    }
+
+    Bitmap aBitmap;
+
+    if (setjmp(png_jmpbuf(pPng)))
+    {
+        png_destroy_read_struct(&pPng, &pInfo, nullptr);
+        return false;
+    }
+
+    // Set our custom stream writer
+    png_set_write_fn(pPng, &rStream, lclWriteStream, nullptr);
+
+    aBitmap = rBitmapEx.GetBitmap();
+
+    {
+        Bitmap::ScopedReadAccess pAccess(aBitmap);
+        Size aSize = rBitmapEx.GetSizePixel();
+
+        int bitDepth = -1;
+        int colorType = -1;
+
+        /* PNG_COLOR_TYPE_GRAY (1, 2, 4, 8, 16)
+           PNG_COLOR_TYPE_GRAY_ALPHA (8, 16)
+           PNG_COLOR_TYPE_PALETTE (bit depths 1, 2, 4, 8)
+           PNG_COLOR_TYPE_RGB (bit_depths 8, 16)
+           PNG_COLOR_TYPE_RGB_ALPHA (bit_depths 8, 16)
+           PNG_COLOR_MASK_PALETTE
+           PNG_COLOR_MASK_COLOR
+           PNG_COLOR_MASK_ALPHA
+        */
+        auto eScanlineFormat = pAccess->GetScanlineFormat();
+        if (eScanlineFormat == ScanlineFormat::N8BitPal && 
aBitmap.HasGreyPalette8Bit())
+        {
+            colorType = PNG_COLOR_TYPE_GRAY;
+            bitDepth = 8;
+        }
+        else if (eScanlineFormat == ScanlineFormat::N24BitTcBgr
+                 || eScanlineFormat == ScanlineFormat::N24BitTcRgb)
+        {
+            colorType = PNG_COLOR_TYPE_RGB;
+            bitDepth = 8;
+            if (eScanlineFormat == ScanlineFormat::N24BitTcBgr)
+                png_set_bgr(pPng);
+        }
+        else
+        {
+            return false;
+        }
+
+        png_set_compression_level(pPng, nCompressionLevel);
+
+        int interlaceType = PNG_INTERLACE_NONE;
+        int compressionType = PNG_COMPRESSION_TYPE_DEFAULT;
+        int filterMethod = PNG_FILTER_TYPE_DEFAULT;
+
+        png_set_IHDR(pPng, pInfo, aSize.Width(), aSize.Height(), bitDepth, 
colorType, interlaceType,
+                     compressionType, filterMethod);
+
+        png_write_info(pPng, pInfo);
+
+        int nNumberOfPasses = 1;
+
+        Scanline pSourcePointer;
+
+        tools::Long nHeight = pAccess->Height();
+
+        for (int nPass = 0; nPass < nNumberOfPasses; nPass++)
+        {
+            for (tools::Long y = 0; y <= nHeight; y++)
+            {
+                pSourcePointer = pAccess->GetScanline(y);
+                png_write_rows(pPng, &pSourcePointer, 1);
+            }
+        }
+    }
+
+    png_write_end(pPng, pInfo);
+
+    png_destroy_write_struct(&pPng, &pInfo);
+
+    return true;
+}
+
+PngImageWriter::PngImageWriter(SvStream& rStream)
+    : mrStream(rStream)
+    , mnCompressionLevel(6)
+    , mbInterlaced(false)
+{
+}
+
+bool PngImageWriter::write(BitmapEx& rBitmapEx)
+{
+    return pngWrite(mrStream, rBitmapEx, mnCompressionLevel);
+}
+
+} // namespace vcl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5692f109d8c7010185ff28e5926f20f27693f7d5
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Nov 12 10:01:20 2020 +0100
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:12 2022 +0900

    basegfx: added LengthUnit class as the base unit for length
    
    Change-Id: I1d4790b60dd784e8b2e2e438274f3ebd6db4b60c

diff --git a/basegfx/CppunitTest_basegfx.mk b/basegfx/CppunitTest_basegfx.mk
index d0a6739a34ef..a19e3d8b55f1 100644
--- a/basegfx/CppunitTest_basegfx.mk
+++ b/basegfx/CppunitTest_basegfx.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,basegfx,\
     basegfx/test/basegfxtools \
     basegfx/test/clipstate \
     basegfx/test/genericclipper \
+    basegfx/test/LengthUnitTest \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
new file mode 100644
index 000000000000..0b80c33da5b0
--- /dev/null
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -0,0 +1,96 @@
+/* -*- 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/.
+ */
+
+#include <basegfx/units/LengthUnit.hxx>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class LengthUnitTest : public CppUnit::TestFixture
+{
+public:
+    void test();
+
+    CPPUNIT_TEST_SUITE(LengthUnitTest);
+    CPPUNIT_TEST(test);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+void LengthUnitTest::test()
+{
+    gfx::LengthUnit cm = 1_cm + 5_cm - 2_cm;
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, cm.as_cm(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm.as_m(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm.as_mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.raw());
+
+    gfx::LengthUnit cm2 = 5_cm * 2;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2.as_cm(), 1e-4);
+
+    // 1 km - 50 m = 950 m = 95000 cm
+    gfx::LengthUnit cm3 = 100000_cm - 5000_cm;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
+
+    gfx::LengthUnit cm4(1_cm);
+    cm4 /= 2;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
+
+    // (635 * 20) + 3 * (635 * 15) = 41275EMU
+    gfx::LengthUnit pt = 1_pt + 3_px;
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, pt.as_twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0451, pt.as_in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(41275), pt.raw());
+
+    gfx::LengthUnit inch = 1_in; // 1440 * 635
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1440.0, inch.as_twip(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, inch.as_px(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch.as_in(), 1e-4);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(914400.0, inch.as_emu(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.raw());
+
+    // Conversion
+    sal_Int64 asNumber(17_pt);
+    asNumber += sal_Int64(1_pt);
+    gfx::LengthUnit asLength = gfx::LengthUnit::emu(asNumber);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.raw());
+
+    gfx::LengthUnit maximum = gfx::LengthUnit::emu(SAL_MAX_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum.as_m(), 1e-1);
+    // 256204778 km
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MAX_INT64), maximum.raw());
+
+    gfx::LengthUnit minimum = gfx::LengthUnit::emu(SAL_MIN_INT64);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum.as_m(), 1e-1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(double(SAL_MIN_INT64), minimum.as_emu(), 
1e-1);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.raw());
+
+    // 27 emu + 33 emu + 360 emu = 420
+    gfx::LengthUnit emus = 27_emu + 33_emu + 1_hmm;
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.raw());
+
+    //  Creation from number
+    int number = 10;
+    auto asCm = gfx::LengthUnit::cm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw());
+
+    auto asMm = gfx::LengthUnit::mm(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw());
+
+    auto asInch = gfx::LengthUnit::in(number);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4);
+    CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(LengthUnitTest);
diff --git a/include/basegfx/units/LengthUnit.hxx 
b/include/basegfx/units/LengthUnit.hxx
new file mode 100644
index 000000000000..4edd1cc4704f
--- /dev/null
+++ b/include/basegfx/units/LengthUnit.hxx
@@ -0,0 +1,194 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+
+namespace gfx
+{
+namespace
+{
+constexpr sal_Int64 constFactor_hmm_to_EMU = 360ll;
+constexpr sal_Int64 constFactor_mm_to_EMU = constFactor_hmm_to_EMU * 100ll;
+constexpr sal_Int64 constFactor_cm_to_EMU = constFactor_hmm_to_EMU * 1000ll;
+constexpr sal_Int64 constFactor_m_to_EMU = constFactor_hmm_to_EMU * 100000ll;
+
+constexpr sal_Int64 constFactor_twip_to_EMU = 635ll;
+constexpr sal_Int64 constFactor_in_to_EMU = constFactor_twip_to_EMU * 1440ll;
+constexpr sal_Int64 constFactor_pt_to_EMU = constFactor_twip_to_EMU * 20ll;
+constexpr sal_Int64 constFactor_px_to_EMU = constFactor_twip_to_EMU * 15ll;
+
+} // end anonymous namespace
+
+template <typename T> class LengthUnitBase
+{
+private:
+    // value in EMU units
+    T m_nValue;
+
+    constexpr explicit LengthUnitBase(T nValue)
+        : m_nValue(nValue)
+    {
+    }
+
+public:
+    static constexpr LengthUnitBase cm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_cm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase mm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_mm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase hmm(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_hmm_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase in(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_in_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase twip(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_twip_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase pt(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_pt_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase px(T nValue)
+    {
+        return LengthUnitBase(gfx::constFactor_px_to_EMU * nValue);
+    }
+
+    static constexpr LengthUnitBase emu(T nValue) { return 
LengthUnitBase(nValue); }
+
+    constexpr explicit LengthUnitBase()
+        : m_nValue(0)
+    {
+    }
+
+    constexpr explicit operator T() const { return m_nValue; }
+
+    constexpr LengthUnitBase& operator+=(LengthUnitBase const& rhs)
+    {
+        m_nValue += rhs.m_nValue;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator-=(LengthUnitBase const& rhs)
+    {
+        m_nValue -= rhs.m_nValue;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator*=(T const& rhs)
+    {
+        m_nValue *= rhs;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator/=(T const& rhs)
+    {
+        m_nValue /= rhs;
+        return *this;
+    }
+
+    constexpr LengthUnitBase& operator-()
+    {
+        m_nValue = -m_nValue;
+        return *this;
+    }
+
+    T raw() const { return m_nValue; }
+
+    double as_hmm() const { return m_nValue / double(constFactor_hmm_to_EMU); }
+    double as_mm() const { return m_nValue / double(constFactor_mm_to_EMU); }
+    double as_cm() const { return m_nValue / double(constFactor_cm_to_EMU); }
+    double as_m() const { return m_nValue / double(constFactor_m_to_EMU); }
+    double as_twip() const { return m_nValue / 
double(constFactor_twip_to_EMU); }
+    double as_in() const { return m_nValue / double(constFactor_in_to_EMU); }
+    double as_pt() const { return m_nValue / double(constFactor_pt_to_EMU); }
+    double as_px() const { return m_nValue / double(constFactor_px_to_EMU); }
+    double as_emu() const { return double(m_nValue); }
+};
+
+template <typename T>
+inline LengthUnitBase<T> operator+(LengthUnitBase<T> lhs, const 
LengthUnitBase<T>& rhs)
+{
+    return lhs += rhs;
+}
+
+template <typename T>
+inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs, const 
LengthUnitBase<T>& rhs)
+{
+    return lhs -= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T> 
lhs, const long rhs)
+{
+    return lhs *= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T> 
lhs, const long rhs)
+{
+    return lhs /= rhs;
+}
+
+typedef LengthUnitBase<sal_Int64> LengthUnit;
+typedef LengthUnitBase<double> LengthUnitD;
+
+} // end namespace gfx
+
+constexpr gfx::LengthUnit operator"" _emu(unsigned long long value)
+{
+    return gfx::LengthUnit::emu(value);
+}
+
+constexpr gfx::LengthUnit operator"" _in(unsigned long long value)
+{
+    return gfx::LengthUnit::in(value);
+}
+
+constexpr gfx::LengthUnit operator"" _cm(unsigned long long value)
+{
+    return gfx::LengthUnit::cm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _mm(unsigned long long value)
+{
+    return gfx::LengthUnit::mm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _hmm(unsigned long long value)
+{
+    return gfx::LengthUnit::hmm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _twip(unsigned long long value)
+{
+    return gfx::LengthUnit::twip(value);
+}
+
+constexpr gfx::LengthUnit operator"" _pt(unsigned long long value)
+{
+    return gfx::LengthUnit::pt(value);
+}
+
+constexpr gfx::LengthUnit operator"" _px(unsigned long long value)
+{
+    return gfx::LengthUnit::px(value);
+}
commit 7d59e907321bcd3af6a431cf6ba517a031190fff
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 15:22:03 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:30:10 2022 +0900

    Benchmark
    
    Change-Id: I22e0ac54380e2d22606e7b1fd453bed843523a29

diff --git a/Repository.mk b/Repository.mk
index 5532b993dfde..360f558c9be5 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
        mtfdemo \
        visualbackendtest \
        listfonts \
+    benchmark \
        $(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), 
gtktiledviewer) \
     $(if $(filter EMSCRIPTEN,$(OS)),wasm-qt5-mandelbrot) \
 ))
diff --git a/vcl/Executable_benchmark.mk b/vcl/Executable_benchmark.mk
new file mode 100644
index 000000000000..c72039c13f7b
--- /dev/null
+++ b/vcl/Executable_benchmark.mk
@@ -0,0 +1,56 @@
+# -*- 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_Executable_Executable,benchmark))
+
+$(eval $(call gb_Executable_use_api,benchmark,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_Executable_use_external,benchmark,boost_headers))
+
+$(eval $(call gb_Executable_set_include,benchmark,\
+    $$(INCLUDE) \
+    -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,benchmark,\
+       basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    tl \
+    sal \
+       salhelper \
+    vcl \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,benchmark,\
+    vcl/backendtest/Benchmark \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+    vclmain \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Executable_add_libs,benchmark,\
+       -lm \
+       -ldl \
+    -lX11 \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+       glxtest \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 62660b718ec1..fb047de395f2 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
             $(if $(filter LINUX MACOSX SOLARIS WNT %BSD,$(OS)), \
                 Executable_vcldemo \
                 Executable_icontest \
+                Executable_benchmark \
                 Executable_visualbackendtest \
                 Executable_mtfdemo \
             ) \
diff --git a/vcl/backendtest/Benchmark.cxx b/vcl/backendtest/Benchmark.cxx
new file mode 100644
index 000000000000..5caef9f6a239
--- /dev/null
+++ b/vcl/backendtest/Benchmark.cxx
@@ -0,0 +1,254 @@
+/* -*- 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/.
+ */
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+
+#include <vcl/virdev.hxx>
+#include <vcl/vclmain.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
+
+#include <chrono>
+#include <iostream>
+#include <tools/ScopedNanoTimer.hxx>
+
+using namespace css;
+
+class Benchmark
+{
+    ScopedVclPtr<VirtualDevice> mpVDev;
+    int mnRepeats;
+
+    Size maSource;
+    Size maTarget;
+
+public:
+    Benchmark()
+        : mpVDev(VclPtr<VirtualDevice>::Create())
+        , mnRepeats(2)
+    {
+        mpVDev->SetAntialiasing(AntialiasingFlags::Enable | 
AntialiasingFlags::PixelSnapHairline);
+        mpVDev->SetOutputSizePixel(Size(4000, 4000));
+        mpVDev->SetBackground(Wallpaper(COL_LIGHTGRAY));
+    }
+
+    void run()
+    {
+        std::vector<sal_Int64> aCompleteTimes(20, 0);
+
+        mnRepeats = 5;
+        for (long iSize : { 4000, 2000, 1000 })
+        {
+            std::vector<std::pair<OUString, sal_Int64>> aTotalTimes(20);
+
+            maSource = Size(iSize, iSize);
+            maTarget = Size(200, 200);
+
+            for (int i = 0; i < mnRepeats; i++)
+            {
+                size_t a = 0;
+                //benchBitmapScale8X(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                //benchBitmapScale8(aTotalTimes[a].first, 
aTotalTimes[a].second); a++;
+                benchBitmapScale24(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale24Combo(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale32(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+                benchBitmapScale32Combo(aTotalTimes[a].first, 
aTotalTimes[a].second);
+                a++;
+
+                /*
+                benchBitmap8X(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;
+                benchBitmap8(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+                benchBitmap24(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;
+                benchBitmap32(aTotalTimes[a].first, aTotalTimes[a].second); 
a++;*/
+            }
+
+            int i = 0;
+            for (auto& rPair : aTotalTimes)
+            {
+                if (!rPair.first.isEmpty())
+                {
+                    aCompleteTimes[i] += rPair.second / double(mnRepeats);
+                    printf("TIME %d: %s - %f\n", i, 
rPair.first.toUtf8().getStr(),
+                           rPair.second / double(mnRepeats));
+                }
+                i++;
+            }
+            printf("\n");
+        }
+        int i = 0;
+        for (auto& rTime : aCompleteTimes)
+        {
+            if (rTime > 0)
+            {
+                printf("TIME %d: %f\n", i, double(rTime));
+                i++;
+            }
+        }
+    }
+
+    void benchBitmapScale8X(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8X Scale";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N8_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Default);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale8(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8 Scale";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Default);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale24(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24 Scale Super";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Default);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale24Combo(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24 Scale Combo";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale32(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32 Scale Super";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Default);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmapScale32Combo(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32 Scale Combo";
+        Bitmap aBitmap(maSource, vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap8X(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8X";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N8_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap8(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "8";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap24(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "24";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N24_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+
+    void benchBitmap32(OUString& rName, sal_Int64& rTotal)
+    {
+        rName = "32";
+        mpVDev->Erase();
+        Bitmap aBitmap(Size(4000, 4000), vcl::PixelFormat::N32_BPP);
+        aBitmap.Erase(COL_YELLOW);
+        ScopedNanoTimer aTimer("32", 1000);
+        mpVDev->DrawBitmap(Point(), aBitmap);
+        rTotal += aTimer.stop();
+    }
+};
+
+class BenchmarkApp : public Application
+{
+public:
+    BenchmarkApp() {}
+
+    virtual int Main() override
+    {
+        Benchmark aBenchmark;
+        aBenchmark.run();
+        return 0;
+    }
+
+protected:
+    void Init() override
+    {
+        try
+        {
+            uno::Reference<uno::XComponentContext> xComponentContext
+                = ::cppu::defaultBootstrap_InitialComponentContext();
+            uno::Reference<lang::XMultiServiceFactory> xMSF
+                = 
uno::Reference<lang::XMultiServiceFactory>(xComponentContext->getServiceManager(),
+                                                             uno::UNO_QUERY);
+
+            if (!xMSF.is())
+                Application::Abort("Bootstrap failure - no service manager");
+
+            comphelper::setProcessServiceFactory(xMSF);
+        }
+        catch (const uno::Exception& e)
+        {
+            Application::Abort("Bootstrap exception " + e.Message);
+        }
+    }
+
+    void DeInit() override
+    {
+        uno::Reference<lang::XComponent> 
xComponent(comphelper::getProcessComponentContext(),
+                                                    uno::UNO_QUERY_THROW);
+        xComponent->dispose();
+        comphelper::setProcessServiceFactory(nullptr);
+    }
+};
+
+void vclmain::createApplication() { static BenchmarkApp aApplication; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 111e5419f066746c013d87236701757d03d56a01
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 11:58:53 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:29:09 2022 +0900

    Update BitmapSymmetryCheck check
    
    Change-Id: I5b0080ebc76f7c1cd118cf5317b06ffe1a1c20df

diff --git a/vcl/inc/BitmapSymmetryCheck.hxx b/vcl/inc/BitmapSymmetryCheck.hxx
index 917b8b6d13a1..ecfe442461f8 100644
--- a/vcl/inc/BitmapSymmetryCheck.hxx
+++ b/vcl/inc/BitmapSymmetryCheck.hxx
@@ -12,18 +12,27 @@
 #define INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
 
 #include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
 
 class BitmapReadAccess;
 
 class VCL_DLLPUBLIC BitmapSymmetryCheck final
 {
+private:
+    std::vector<std::pair<Point, Point>> maNonSymmetricPoints;
+    Size maSize;
+
 public:
     BitmapSymmetryCheck();
 
-    static bool check(Bitmap& rBitmap);
+public:
+    BitmapSymmetryCheck() = default;
+    bool check(Bitmap& rBitmap);
+    BitmapEx getErrorBitmap();
 
 private:
-    static bool checkImpl(BitmapReadAccess const* pReadAccess);
+    bool checkImpl(BitmapReadAccess const* pReadAccess);
+    void addNewError(Point const& rPoint1, Point const& rPoint2);
 };
 
 #endif // INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx 
b/vcl/qa/cppunit/BitmapFilterTest.cxx
index a2aa37ceb900..310cf67e8f5b 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -127,7 +127,9 @@ void BitmapFilterTest::testBlurCorrectness()
     CPPUNIT_ASSERT_EQUAL(ePixelFormat, aBitmap24Bit.getPixelFormat());
 
     // Check that the bitmap is horizontally and vertically symmetrical
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
+    BitmapSymmetryCheck aBitmapSymmetryCheck;
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap24Bit);
+    CPPUNIT_ASSERT(bSymmetryCheckResult);
 
     {
         Bitmap::ScopedReadAccess aReadAccess(aBitmap24Bit);
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx 
b/vcl/qa/cppunit/BitmapScaleTest.cxx
index ce8f67437d9d..62764b8a11a4 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -18,19 +18,84 @@
 
 #include <BitmapSymmetryCheck.hxx>
 #include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/BitmapTools.hxx>
+
+#include <svdata.hxx>
+#include <salinst.hxx>
 
 namespace
 {
 class BitmapScaleTest : public CppUnit::TestFixture
 {
+    static constexpr const bool mbExportBitmap = true;
+
+    void exportImage(OUString const& rsFilename, Bitmap const& rBitmap)
+    {
+        if (mbExportBitmap)
+        {
+            SvFileStream aStream(rsFilename, StreamMode::WRITE | 
StreamMode::TRUNC);
+            GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+            if (rBitmap.GetBitCount() == 32)
+            {
+                BitmapEx aBitmapConverted;
+                vcl::bitmap::convertBitmap32To24Plus8(BitmapEx(rBitmap), 
aBitmapConverted);
+                rFilter.compressAsPNG(aBitmapConverted, aStream);
+            }
+            else
+            {
+                rFilter.compressAsPNG(BitmapEx(rBitmap), aStream);
+            }
+        }
+    }
+
+    Bitmap createUpscaleTestImage(vcl::PixelFormat ePixelFormat)
+    {
+        long w = 10;
+        long h = 10;
+        Bitmap aBitmap(Size(w, h), ePixelFormat);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(ePixelFormat == vcl::PixelFormat::N32_BPP ? 
COL_TRANSPARENT
+                                                                          : 
COL_WHITE);
+            aWriteAccess->SetLineColor(COL_LIGHTRED);
+            aWriteAccess->DrawRect(tools::Rectangle(1, 1, w - 1 - 1, h - 1 - 
1));
+            aWriteAccess->SetLineColor(COL_LIGHTGREEN);
+            aWriteAccess->DrawRect(tools::Rectangle(3, 3, w - 1 - 3, h - 1 - 
3));
+            aWriteAccess->SetLineColor(COL_LIGHTBLUE);
+            aWriteAccess->DrawRect(tools::Rectangle(5, 5, w - 1 - 5, h - 1 - 
5));
+        }
+        return aBitmap;
+    }
+
+    Bitmap createDownscaleTestImage(vcl::PixelFormat ePixelFormat)
+    {
+        long w = 20;
+        long h = 20;
+        Bitmap aBitmap(Size(w, h), ePixelFormat);
+        {
+            BitmapScopedWriteAccess aWriteAccess(aBitmap);
+            aWriteAccess->Erase(ePixelFormat == vcl::PixelFormat::N32_BPP ? 
COL_TRANSPARENT
+                                                                          : 
COL_WHITE);
+            aWriteAccess->SetLineColor(COL_LIGHTRED);
+            aWriteAccess->DrawRect(tools::Rectangle(2, 2, w - 1 - 2, h - 1 - 
2));
+            aWriteAccess->SetLineColor(COL_LIGHTGREEN);
+            aWriteAccess->DrawRect(tools::Rectangle(5, 5, w - 1 - 5, h - 1 - 
5));
+            aWriteAccess->SetLineColor(COL_LIGHTBLUE);
+            aWriteAccess->DrawRect(tools::Rectangle(8, 8, w - 1 - 8, h - 1 - 
8));
+        }
+        return aBitmap;
+    }
+
     void testScale();
     void testScale2();
-    void testScaleSymmetry();
+    void testScaleSymmetryUp24();
+    void testScaleSymmetryDown24();
 
     CPPUNIT_TEST_SUITE(BitmapScaleTest);
     CPPUNIT_TEST(testScale);
     CPPUNIT_TEST(testScale2);
-    CPPUNIT_TEST(testScaleSymmetry);
+    CPPUNIT_TEST(testScaleSymmetryUp24);
+    CPPUNIT_TEST(testScaleSymmetryDown24);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -258,51 +323,63 @@ void BitmapScaleTest::testScale2()
     CPPUNIT_ASSERT(checkBitmapColor(aScaledBitmap, aBitmapColor));
 }
 
-void BitmapScaleTest::testScaleSymmetry()
+void BitmapScaleTest::testScaleSymmetryUp24()
 {
-    const bool bExportBitmap(false);
+    Bitmap aBitmap = createUpscaleTestImage(vcl::PixelFormat::N24_BPP);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    exportImage("~/scale_up_24_before.png", aBitmap);
 
-    Bitmap aBitmap24Bit(Size(10, 10), vcl::PixelFormat::N24_BPP);
-    CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, 
aBitmap24Bit.getPixelFormat());
-
-    {
-        BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit);
-        aWriteAccess->Erase(COL_WHITE);
-        aWriteAccess->SetLineColor(COL_BLACK);
-        aWriteAccess->DrawRect(tools::Rectangle(1, 1, 8, 8));
-        aWriteAccess->DrawRect(tools::Rectangle(3, 3, 6, 6));
-    }
+    CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(10), aBitmap.GetSizePixel().Height());
 
     BitmapSymmetryCheck aBitmapSymmetryCheck;
+    // Check symmetry of the bitmap
+    CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
+
+    aBitmap.Scale(2, 2);
+
+    CPPUNIT_ASSERT_EQUAL(tools::Long(20), aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(tools::Long(20), aBitmap.GetSizePixel().Height());
+
+    exportImage("~/scale_up_24_after.png", aBitmap);
+
+    // After scaling the bitmap should still be symmetrical. This check 
guarantees that
+    // scaling doesn't misalign the bitmap.
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap);
+    if (!bSymmetryCheckResult)
+        exportImage("~/scale_up_24_after_error.png",
+                    aBitmapSymmetryCheck.getErrorBitmap().GetBitmap());
+
+    // CPPUNIT_ASSERT(bSymmetryCheckResult);
+}
+
+void BitmapScaleTest::testScaleSymmetryDown24()
+{
+    Bitmap aBitmap = createDownscaleTestImage(vcl::PixelFormat::N24_BPP);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(24), aBitmap.GetBitCount());
+    exportImage("~/scale_down_24_before.png", aBitmap);
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap24Bit.GetSizePixel().Width());
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap24Bit.GetSizePixel().Height());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap.GetSizePixel().Height());
 
+    BitmapSymmetryCheck aBitmapSymmetryCheck;
     // Check symmetry of the bitmap
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
+    CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
 
-    if (bExportBitmap)
-    {
-        SvFileStream aStream("~/scale_before.png", StreamMode::WRITE | 
StreamMode::TRUNC);
-        GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
-        rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream);
-    }
+    aBitmap.Scale(0.5, 0.5);
 
-    aBitmap24Bit.Scale(2, 2, BmpScaleFlag::Fast);
+    exportImage("~/scale_down_24_after.png", aBitmap);
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap24Bit.GetSizePixel().Width());
-    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(20), 
aBitmap24Bit.GetSizePixel().Height());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap.GetSizePixel().Width());
+    CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(10), 
aBitmap.GetSizePixel().Height());
 
     // After scaling the bitmap should still be symmetrical. This check 
guarantees that
     // scaling doesn't misalign the bitmap.
-    CPPUNIT_ASSERT(BitmapSymmetryCheck::check(aBitmap24Bit));
-
-    if (bExportBitmap)
-    {
-        SvFileStream aStream("~/scale_after.png", StreamMode::WRITE | 
StreamMode::TRUNC);
-        GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
-        rFilter.compressAsPNG(BitmapEx(aBitmap24Bit), aStream);
-    }
+    bool bSymmetryCheckResult = aBitmapSymmetryCheck.check(aBitmap);
+    if (!bSymmetryCheckResult)
+        exportImage("~/scale_down_24_after_error.png",
+                    aBitmapSymmetryCheck.getErrorBitmap().GetBitmap());
+    // CPPUNIT_ASSERT(aBitmapSymmetryCheck.check(aBitmap));
 }
 
 } // namespace
diff --git a/vcl/source/bitmap/BitmapSymmetryCheck.cxx 
b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
index 1bd16e815400..6a86e30ef7e8 100644
--- a/vcl/source/bitmap/BitmapSymmetryCheck.cxx
+++ b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
@@ -8,6 +8,7 @@
  *
  */
 
+#include <bitmap/BitmapWriteAccess.hxx>
 #include <vcl/BitmapReadAccess.hxx>
 
 #include <BitmapSymmetryCheck.hxx>
@@ -23,9 +24,13 @@ bool BitmapSymmetryCheck::check(Bitmap& rBitmap)
 
 bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const * pReadAccess)
 {
+    maNonSymmetricPoints.clear();
+
     tools::Long nHeight = pReadAccess->Height();
     tools::Long nWidth = pReadAccess->Width();
 
+    maSize = Size(nWidth, nHeight);
+
     tools::Long nHeightHalf = nHeight / 2;
     tools::Long nWidthHalf = nWidth / 2;
 
@@ -34,22 +39,21 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const 
* pReadAccess)
 
     for (tools::Long y = 0; y < nHeightHalf; ++y)
     {
-        Scanline pScanlineRead = pReadAccess->GetScanline( y );
-        Scanline pScanlineRead2 = pReadAccess->GetScanline( nHeight - y - 1 );
+
+        tools::Long y2 = nHeight - y - 1;
+
+        Scanline pScanlineRead1 = pReadAccess->GetScanline(y);
+        Scanline pScanlineRead2 = pReadAccess->GetScanline(y2);
         for (tools::Long x = 0; x < nWidthHalf; ++x)
         {
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x))
-            {
-                return false;
-            }
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
-            {
-                return false;
-            }
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, nWidth - x - 1))
-            {
-                return false;
-            }
+            tools::Long x2 = nWidth - x - 1;
+
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x))
+                addNewError(Point(x, y), Point(x, y2));
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead1, x2))
+                addNewError(Point(x, y), Point(x2, y));
+            if (pReadAccess->GetPixelFromData(pScanlineRead1, x) != 
pReadAccess->GetPixelFromData(pScanlineRead2, x2))
+                addNewError(Point(x, y), Point(x2, y2));
         }
     }
 
@@ -57,10 +61,9 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const * 
pReadAccess)
     {
         for (tools::Long y = 0; y < nHeightHalf; ++y)
         {
-            if (pReadAccess->GetPixel(y, nWidthHalf) != 
pReadAccess->GetPixel(nHeight - y - 1, nWidthHalf))
-            {
-                return false;
-            }
+            tools::Long y2 = nHeight - y - 1;
+            if (pReadAccess->GetPixel(y, nWidthHalf) != 
pReadAccess->GetPixel(y2, nWidthHalf))
+                addNewError(Point(nWidthHalf, y), Point(nWidthHalf, y2));
         }
     }
 
@@ -69,14 +72,38 @@ bool BitmapSymmetryCheck::checkImpl(BitmapReadAccess const 
* pReadAccess)
         Scanline pScanlineRead = pReadAccess->GetScanline( nHeightHalf );
         for (tools::Long x = 0; x < nWidthHalf; ++x)
         {
-            if (pReadAccess->GetPixelFromData(pScanlineRead, x) != 
pReadAccess->GetPixelFromData(pScanlineRead, nWidth - x - 1))
-            {
-                return false;
-            }
+            tools::Long x2 = nWidth - x - 1;
+            BitmapColor c1 = pReadAccess->GetPixelFromData(pScanlineRead, x);
+            BitmapColor c2 = pReadAccess->GetPixelFromData(pScanlineRead, x2);
+            if (c1 != c2)
+                addNewError(Point(x, nHeightHalf), Point(x2, nHeightHalf));
         }
     }
 
-    return true;
+    return maNonSymmetricPoints.empty();
+}
+
+void BitmapSymmetryCheck::addNewError(Point const & rPoint1, Point const & 
rPoint2)
+{
+    maNonSymmetricPoints.emplace_back(rPoint1, rPoint2);
+}
+
+BitmapEx BitmapSymmetryCheck::getErrorBitmap()
+{
+    if (maSize == Size() || maNonSymmetricPoints.empty())
+        return BitmapEx();
+
+    Bitmap aBitmap(maSize, vcl::PixelFormat::N24_BPP);
+    {
+        BitmapScopedWriteAccess pWrite(aBitmap);
+        pWrite->Erase(COL_BLACK);
+        for (auto const & rPairOfPoints : maNonSymmetricPoints)
+        {
+            pWrite->SetPixel(rPairOfPoints.first.Y(), rPairOfPoints.first.X(), 
COL_LIGHTRED);
+            pWrite->SetPixel(rPairOfPoints.second.Y(), 
rPairOfPoints.second.X(), COL_LIGHTGREEN);
+        }
+    }
+    return BitmapEx(aBitmap);
 }
 
 
commit d3b1d4593ffd38dc7f37ece883669fb5f5afdbdb
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Aug 29 11:44:21 2020 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Wed May 11 17:27:15 2022 +0900

    Combo image down-scaler and HalfScaler
    
    Change-Id: I2c422f983e378cff47c5534f0f2774ffb41e2a25

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index d27ffdaa8559..120ec594bd9b 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -61,7 +61,8 @@ enum class BmpScaleFlag
     Interpolate, // fast, integer bilinear
     Lanczos,
     BiCubic,
-    BiLinear
+    BiLinear,
+    Combo
 };
 
 #define BMP_COL_TRANS               Color( 252, 3, 251 )
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a141e22348dd..366e991a2e16 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -362,6 +362,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/bitmap/BitmapSeparableUnsharpenFilter \
     vcl/source/bitmap/BitmapFastScaleFilter \
     vcl/source/bitmap/BitmapScaleSuperFilter \
+    vcl/source/bitmap/BitmapComboScaleFilter \
     vcl/source/bitmap/BitmapScaleConvolutionFilter \
     vcl/source/bitmap/BitmapSymmetryCheck \
     vcl/source/bitmap/BitmapColorQuantizationFilter \

... etc. - the rest is truncated

Reply via email to