[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - desktop/source include/LibreOfficeKit
Henry Castro
hcastro at collabora.com
Tue Nov 15 04:02:38 UTC 2016
desktop/source/lib/init.cxx | 10 ++++++++--
include/LibreOfficeKit/LibreOfficeKit.h | 1 +
include/LibreOfficeKit/LibreOfficeKit.hxx | 5 +++--
3 files changed, 12 insertions(+), 4 deletions(-)
New commits:
commit fe41bbef2d6abefda2668d76ddffef519410b645
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Nov 11 16:29:57 2016 -0400
lok: add character parameter to renderFont
When client side request special character, it is very useful to send a
preview of the rendered font character
Conflicts:
desktop/source/lib/init.cxx
Reviewed-on: https://gerrit.libreoffice.org/30784
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Conflicts:
desktop/source/lib/init.cxx
Change-Id: I1f5727163dfcc861add121e616bdb17881c28197
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e038437..3155ef0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -479,6 +479,7 @@ static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t nSize);
static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
const char *pFontName,
+ const char *pChar,
int* pFontWidth,
int* pFontHeight);
static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
@@ -2475,12 +2476,14 @@ static bool doc_getViewIds(LibreOfficeKitDocument* /*pThis*/, int* pArray, size_
unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
const char* pFontName,
+ const char* pChar,
int* pFontWidth,
int* pFontHeight)
{
SolarMutexGuard aGuard;
OString aSearchedFontName(pFontName);
+ OUString aText(OStringToOUString(pChar, RTL_TEXTENCODING_UTF8));
SfxObjectShell* pDocSh = SfxObjectShell::Current();
const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(
pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
@@ -2496,6 +2499,9 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
if (!aSearchedFontName.equals(aFontName.toUtf8().getStr()))
continue;
+ if (aText.isEmpty())
+ aText = rInfo.GetFamilyName();
+
auto aDevice(
VclPtr<VirtualDevice>::Create(
nullptr, Size(1, 1), DeviceFormat::DEFAULT));
@@ -2503,7 +2509,7 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
vcl::Font aFont(rInfo);
aFont.SetSize(Size(0, 25));
aDevice->SetFont(aFont);
- aDevice->GetTextBoundRect(aRect, aFontName);
+ aDevice->GetTextBoundRect(aRect, aText);
int nFontWidth = aRect.BottomRight().X() + 1;
*pFontWidth = nFontWidth;
int nFontHeight = aRect.BottomRight().Y() + 1;
@@ -2517,7 +2523,7 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
aDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nFontWidth, nFontHeight), Fraction(1.0), Point(),
aBuffer);
- aDevice->DrawText(Point(0,0), aFontName);
+ aDevice->DrawText(Point(0,0), aText);
return pBuffer;
}
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c97655f..c7a2130 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -225,6 +225,7 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::renderFont().
unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis,
const char* pFontName,
+ const char* pChar,
int* pFontWidth,
int* pFontHeight);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 0c52843..887bf36 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -404,14 +404,15 @@ public:
}
/**
- * Paints a font name to be displayed in the font list
+ * Paints a font name or character if provided to be displayed in the font list
* @param pFontName the font to be painted
*/
inline unsigned char* renderFont(const char *pFontName,
+ const char *pChar,
int *pFontWidth,
int *pFontHeight)
{
- return mpDoc->pClass->renderFont(mpDoc, pFontName, pFontWidth, pFontHeight);
+ return mpDoc->pClass->renderFont(mpDoc, pFontName, pChar, pFontWidth, pFontHeight);
}
/**
More information about the Libreoffice-commits
mailing list