desktop/source/lib/init.cxx                    |   27 ++++++++++++++++++++++---
 include/LibreOfficeKit/LibreOfficeKit.hxx      |    4 +++
 include/LibreOfficeKit/LibreOfficeKitInit.h    |    2 +
 include/vcl/outdev.hxx                         |    4 +--
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |    7 ++++++
 5 files changed, 39 insertions(+), 5 deletions(-)

New commits:
commit cef57d2bfa19d249e1c1721f32640f955a137955
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Wed Mar 9 11:33:16 2022 +0200
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Wed Apr 13 12:54:33 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.
    
    Change-Id: I6fe61919daa5af29e964cec1caf7293aefa8ea4f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131250
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3e4265969053..8f991c37f818 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4161,6 +4161,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(true);
+        pDevice->AddTempDevFont(OUString::fromUtf8(OString(pValue)), "");
+        OutputDevice::ImplRefreshAllFontData(true);
+    }
 }
 
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* 
pCommand, const char* pArguments, bool bNotifyWhenFinished)
@@ -6528,7 +6535,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
@@ -6815,11 +6826,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);
@@ -6840,6 +6852,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 2a4a8fd72661..507d1c5202b5 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -1037,6 +1037,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 8a48bd8392be..b1bfd2b54d7f 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -249,6 +249,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/vcl/outdev.hxx b/include/vcl/outdev.hxx
index ac5fa932a5b0..06f902388a8b 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1286,10 +1286,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 0abddcdd9c09..8e03eddc1929 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -106,12 +106,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;
         }
@@ -119,7 +123,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 );
     }
 

Reply via email to