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 5de22d1e559cd0f1f5fa4e247f0ce153710fbeab
Author:     Tor Lillqvist <[email protected]>
AuthorDate: Wed Mar 9 11:33:16 2022 +0200
Commit:     Tor Lillqvist <[email protected]>
CommitDate: Wed Apr 13 12:54:04 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/+/132948
    Tested-by: Tor Lillqvist <[email protected]>
    Reviewed-by: Tor Lillqvist <[email protected]>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 33b763b3a1cb..442297d5d348 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4113,6 +4113,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(pValue), "");
+        OutputDevice::ImplRefreshAllFontData(true);
+    }
 }
 
 static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* 
pCommand, const char* pArguments, bool bNotifyWhenFinished)
@@ -6476,7 +6483,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
@@ -6760,11 +6771,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);
@@ -6785,6 +6797,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 b00d1c1c8236..4e9c3105c844 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 d244638e5127..7dacb68d55ad 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1180,10 +1180,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 193b98f9ef94..39fee3853dce 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -105,12 +105,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;
         }
@@ -118,7 +122,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