summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2022-03-09 11:33:16 +0200
committerTor Lillqvist <tml@collabora.com>2022-04-13 12:54:33 +0200
commitcef57d2bfa19d249e1c1721f32640f955a137955 (patch)
tree711037ceb57708b02f924d4476b3a9d4b0343869
parent[cp] This label is too long for Online context menus (diff)
downloadcore-cef57d2bfa19d249e1c1721f32640f955a137955.tar.gz
core-cef57d2bfa19d249e1c1721f32640f955a137955.zip
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--desktop/source/lib/init.cxx27
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx4
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h2
-rw-r--r--include/vcl/outdev.hxx4
-rw-r--r--vcl/unx/generic/glyphs/freetype_glyphcache.cxx7
5 files changed, 39 insertions, 5 deletions
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 );
}