desktop/source/lib/init.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
New commits: commit c1716f183431b700ea325f3259c18273c4c9cda5 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Thu Feb 20 08:39:54 2025 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Feb 22 22:08:23 2025 +0100 preload typedetection to share it with children. Change-Id: Ia212dbf44899932880180185977e74cfbfac34c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182010 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182039 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 8fc9d592310b..84f7de8a22a2 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -95,6 +95,7 @@ #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/DispatchResultEvent.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> @@ -7730,6 +7731,31 @@ static void preLoadShortCutAccelerators() batch->commit(); } +static void preLoadTypeDetection() +{ + uno::Reference<document::XTypeDetection> xTypeDetection( + xFactory->createInstanceWithContext(u"com.sun.star.document.TypeDetection"_ustr, xContext), + uno::UNO_QUERY); + if (xTypeDetection) + { + SvMemoryStream aMemory; + // just enough to check zip based type detection + const sal_uInt8 aMinimalZip[30] = { 0x50, 0x4b, 0x03, 0x04, + 0x14, 0x00, 0x00, 0x08 }; + aMemory.WriteBytes(aMinimalZip, std::size(aMinimalZip)); + uno::Reference<io::XStream> xInputStream = new utl::OStreamWrapper(aMemory); + + uno::Sequence<beans::PropertyValue> aMediaDesc(2); + auto pArgs = aMediaDesc.getArray(); + pArgs[0].Name = "URL"; + pArgs[0].Value <<= OUString("private:stream"); + pArgs[1].Name = "InputStream"; + pArgs[1].Value <<= xInputStream; + + xTypeDetection->queryTypeByDescriptor(aMediaDesc, true); + } +} + /// Used only by LibreOfficeKit when used by Online to pre-initialize static void preloadData() { @@ -7907,6 +7933,9 @@ static void preloadData() xComp->dispose(); } + // Preload typedetection + preLoadTypeDetection(); + // Set user profile's path back to the original one rtl::Bootstrap::set(u"UserInstallation"_ustr, sUserPath);