[Libreoffice-commits] online.git: 3 commits - loleaflet/src loolwsd/bundled loolwsd/ChildSession.cpp loolwsd/ClientSession.cpp loolwsd/LibreOfficeKit.hpp loolwsd/PrisonerSession.cpp
Henry Castro
hcastro at collabora.com
Tue Nov 15 04:04:59 UTC 2016
loleaflet/src/control/Control.CharacterMap.js | 9 +++++----
loolwsd/ChildSession.cpp | 10 ++++++----
loolwsd/ClientSession.cpp | 6 ++++--
loolwsd/LibreOfficeKit.hpp | 3 ++-
loolwsd/PrisonerSession.cpp | 8 +++++---
loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h | 1 +
6 files changed, 23 insertions(+), 14 deletions(-)
New commits:
commit c40b79df9e00c0c586dcf75c7abb474d2e506df0
Author: Henry Castro <hcastro at collabora.com>
Date: Mon Nov 14 22:49:56 2016 -0400
loleaflet: enable font character preview
diff --git a/loleaflet/src/control/Control.CharacterMap.js b/loleaflet/src/control/Control.CharacterMap.js
index 77091ab..d204a08 100644
--- a/loleaflet/src/control/Control.CharacterMap.js
+++ b/loleaflet/src/control/Control.CharacterMap.js
@@ -208,10 +208,11 @@ L.Control.CharacterMap = L.Control.extend({
},
_onFontNamesChange: function (e) {
- /* if (this._hexa.data) {
+ if (this._hexa.data) {
+ this._map._socket.sendMessage('renderfont font=' +
window.encodeURIComponent(this._fontNames.options[this._fontNames.selectedIndex].value) +
' char=' + String.fromCharCode(this._hexa.data));
- }*/
+ }
},
_onInsertClick: function (e) {
@@ -239,9 +240,9 @@ L.Control.CharacterMap = L.Control.extend({
var target = e.target || e.srcElement;
this._hexa.data = target.data;
this._hexa.innerHTML = 'U+' + target.data.toString(16).toUpperCase();
- /*this._map._socket.sendMessage('renderfont font=' +
+ this._map._socket.sendMessage('renderfont font=' +
window.encodeURIComponent(this._fontNames.options[this._fontNames.selectedIndex].value) +
- ' char=' + String.fromCharCode(this._hexa.data));*/
+ ' char=' + String.fromCharCode(this._hexa.data));
},
_onUnicodeChartChange: function (e) {
commit 4ea95ff3304355a6ac34d8c916296cfb1eb17027
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Nov 11 13:24:13 2016 -0400
loolwsd: add parameter char to render font
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 4a177ac..c28cfbf 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -356,15 +356,17 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
- std::string font, decodedFont;
+ std::string font, text, decodedFont;
- if (tokens.count() < 2 ||
+ if (tokens.count() < 3 ||
!getTokenString(tokens[1], "font", font))
{
sendTextFrame("error: cmd=renderfont kind=syntax");
return false;
}
+ getTokenString(tokens[2], "char", text);
+
URI::decode(font, decodedFont);
std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
@@ -381,7 +383,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str
_loKitDocument->setView(_viewId);
- ptrFont = _loKitDocument->renderFont(decodedFont.c_str(), &width, &height);
+ ptrFont = _loKitDocument->renderFont(decodedFont.c_str(), text.c_str(), &width, &height);
}
LOG_TRC("renderFont [" << font << "] rendered in " << (timestamp.elapsed()/1000.) << "ms");
@@ -394,7 +396,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str
}
std::free(ptrFont);
- return sendBinaryFrame(output.data(), output.size());
+ return sendTextFrame(output.data(), output.size());
}
bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/)
diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index 93d68df..00a0a3f 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -319,20 +319,22 @@ bool ClientSession::getPartPageRectangles(const char *buffer, int length,
bool ClientSession::sendFontRendering(const char *buffer, int length, StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker)
{
- std::string font;
+ std::string font, text, encodedChar;
if (tokens.count() < 2 ||
!getTokenString(tokens[1], "font", font))
{
return sendTextFrame("error: cmd=renderfont kind=syntax");
}
+ getTokenString(tokens[2], "char", text);
+ Poco::URI::encode(text, "", encodedChar);
const std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
std::vector<char> output;
output.resize(response.size());
std::memcpy(output.data(), response.data(), response.size());
- std::unique_ptr<std::fstream> cachedRendering = docBroker->tileCache().lookupCachedFile(font, "font");
+ std::unique_ptr<std::fstream> cachedRendering = docBroker->tileCache().lookupCachedFile(font+encodedChar, "font");
if (cachedRendering && cachedRendering->is_open())
{
cachedRendering->seekg(0, std::ios_base::end);
diff --git a/loolwsd/LibreOfficeKit.hpp b/loolwsd/LibreOfficeKit.hpp
index cab4cbe..fe54938 100644
--- a/loolwsd/LibreOfficeKit.hpp
+++ b/loolwsd/LibreOfficeKit.hpp
@@ -461,10 +461,11 @@ public:
* @param pFontName the font to be painted
*/
inline unsigned char* renderFont(const char *pFontName,
+ const char *pChar,
int *pFontWidth,
int *pFontHeight)
{
- return _pDoc->pClass->renderFont(_pDoc, pFontName, pFontWidth, pFontHeight);
+ return _pDoc->pClass->renderFont(_pDoc, pFontName, pChar, pFontWidth, pFontHeight);
}
/**
diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp
index a7cfa3a..bb352cc 100644
--- a/loolwsd/PrisonerSession.cpp
+++ b/loolwsd/PrisonerSession.cpp
@@ -231,16 +231,18 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
}
else if (tokens[0] == "renderfont:")
{
- std::string font;
- if (tokens.count() < 2 ||
+ std::string font, text, encodedChar;
+ if (tokens.count() < 3 ||
!getTokenString(tokens[1], "font", font))
{
LOG_ERR("Bad syntax for: " << firstLine);
return false;
}
+ getTokenString(tokens[2], "char", text);
+ Poco::URI::encode(text, "", encodedChar);
assert(firstLine.size() < static_cast<std::string::size_type>(length));
- _docBroker->tileCache().saveRendering(font, "font", buffer + firstLine.size() + 1, length - firstLine.size() - 1);
+ _docBroker->tileCache().saveRendering(font+encodedChar, "font", buffer + firstLine.size() + 1, length - firstLine.size() - 1);
}
}
else
commit b7d3ea63ffffb9172d5fd6bb1c50b2e4ffca1569
Author: Henry Castro <hcastro at collabora.com>
Date: Mon Nov 14 22:57:40 2016 -0400
loolwsd: update bundled headers
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
index c97655f..c7a2130 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/loolwsd/bundled/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);
More information about the Libreoffice-commits
mailing list