desktop/source/lib/init.cxx | 27 ++++++++++++++++++++++--- include/LibreOfficeKit/LibreOfficeKit.hxx | 4 +++ include/LibreOfficeKit/LibreOfficeKitInit.h | 2 + include/sal/log-areas.dox | 1 include/vcl/outdev.hxx | 4 +-- vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 7 ++++++ 6 files changed, 40 insertions(+), 5 deletions(-)
New commits: commit 7eec383744f6e5c36362ef22e2fd0c526e3077b1 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Wed Mar 9 11:33:16 2022 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Thu Apr 14 03:05:03 2022 +0200 Handle "addfont" from Collabora Online We use the AddTempDevFont() API to add a new font. Sadly there is no corresponding way to remove such a temporarily added font. In this branch this commit also includes a follow-up fix to avoid an assertion failure (in a build with assertions). Change-Id: I6fe61919daa5af29e964cec1caf7293aefa8ea4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132948 Tested-by: Tor Lillqvist <t...@collabora.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132967 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 18259e045415..82bb8715960b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4119,6 +4119,13 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const c else sal_detail_set_log_selector(pCurrentSalLogOverride); } + else if (strcmp(pOption, "addfont") == 0) + { + OutputDevice *pDevice = Application::GetDefaultDevice(); + OutputDevice::ImplClearAllFontData(false); + pDevice->AddTempDevFont(OUString::fromUtf8(pValue), ""); + OutputDevice::ImplRefreshAllFontData(false); + } } static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished) @@ -6482,7 +6489,11 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char // What stage are we at ? if (pThis == nullptr) + { eStage = PRE_INIT; + SAL_INFO("lok", "Create libreoffice object"); + gImpl = new LibLibreOffice_Impl(); + } else if (bPreInited) eStage = SECOND_INIT; else @@ -6766,11 +6777,12 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char SAL_JNI_EXPORT LibreOfficeKit *libreofficekit_hook_2(const char* install_path, const char* user_profile_url) { - if (!gImpl) + static bool alreadyCalled = false; + + if (!alreadyCalled) { - SAL_INFO("lok", "Create libreoffice object"); + alreadyCalled = true; - gImpl = new LibLibreOffice_Impl(); if (!lo_initialize(gImpl, install_path, user_profile_url)) { lo_destroy(gImpl); @@ -6791,6 +6803,15 @@ int lok_preinit(const char* install_path, const char* user_profile_url) return lo_initialize(nullptr, install_path, user_profile_url); } +SAL_JNI_EXPORT +int lok_preinit_2(const char* install_path, const char* user_profile_url, LibLibreOffice_Impl** kit) +{ + int result = lo_initialize(nullptr, install_path, user_profile_url); + if (kit != nullptr) + *kit = gImpl; + return result; +} + static void lo_destroy(LibreOfficeKit* pThis) { SolarMutexClearableGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 064caae2729b..912b3e0d2203 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -1036,6 +1036,10 @@ public: * environment variable SAL_LOG is again used as by default. You * can switch back and forth as you like. * + * "addfont": "<string>" + * + * Adds the font at the URL given. + * * @param pOption the option name * @param pValue its value */ diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h index ccd42863ba25..5bbb722b5b18 100644 --- a/include/LibreOfficeKit/LibreOfficeKitInit.h +++ b/include/LibreOfficeKit/LibreOfficeKitInit.h @@ -255,6 +255,8 @@ typedef LibreOfficeKit *(LokHookFunction2)( const char *install_path, const char typedef int (LokHookPreInit) ( const char *install_path, const char *user_profile_url ); +typedef int (LokHookPreInit2) ( const char *install_path, const char *user_profile_url, LibreOfficeKit** kit); + #if defined(IOS) || defined(ANDROID) LibreOfficeKit *libreofficekit_hook_2(const char* install_path, const char* user_profile_path); #endif diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index 9a623b88dc8f..b1f8bb99723a 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -509,6 +509,7 @@ certain functionality. @li @c vcl.uitest - The UI testing framework code @li @c vcl.unity @li @c vcl.unx.dtrans +@li @c vcl.unx.freetype @li @c vcl.unx.print @li @c vcl.virdev @li @c vcl.watchdog diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 85670e44dec3..753007e17cf1 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1189,10 +1189,10 @@ public: //drop font data for all outputdevices. //If bNewFontLists is true then empty lists of system fonts - SAL_DLLPRIVATE static void ImplClearAllFontData( bool bNewFontLists ); + static void ImplClearAllFontData( bool bNewFontLists ); //fetch font data for all outputdevices //If bNewFontLists is true then fetch lists of system fonts - SAL_DLLPRIVATE static void ImplRefreshAllFontData( bool bNewFontLists ); + static void ImplRefreshAllFontData( bool bNewFontLists ); //drop and fetch font data for all outputdevices //If bNewFontLists is true then drop and refetch lists of system fonts SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists ); diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index f199074a75c7..b19b6bb96446 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -104,12 +104,16 @@ bool FreetypeFontFile::Map() const char* pFileName = maNativeFileName.getStr(); int nFile = open( pFileName, O_RDONLY ); if( nFile < 0 ) + { + SAL_WARN("vcl.unx.freetype", "open('" << maNativeFileName << "') failed: " << strerror(errno)); return false; + } struct stat aStat; int nRet = fstat( nFile, &aStat ); if (nRet < 0) { + SAL_WARN("vcl.unx.freetype", "fstat on '" << maNativeFileName << "' failed: " << strerror(errno)); close (nFile); return false; } @@ -117,7 +121,10 @@ bool FreetypeFontFile::Map() mpFileMap = static_cast<unsigned char*>( mmap( nullptr, mnFileSize, PROT_READ, MAP_SHARED, nFile, 0 )); if( mpFileMap == MAP_FAILED ) + { + SAL_WARN("vcl.unx.freetype", "mmap of '" << maNativeFileName << "' failed: " << strerror(errno)); mpFileMap = nullptr; + } close( nFile ); }