summaryrefslogtreecommitdiff
path: root/desktop/source/lib/init.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/lib/init.cxx')
-rw-r--r--desktop/source/lib/init.cxx59
1 files changed, 59 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3155ef0e5f1a..bc724a68f16d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -67,6 +67,7 @@
#include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc>
#include <svx/svxids.hrc>
+#include <svx/ucsubset.hxx>
#include <vcl/svapp.hxx>
#include <vcl/svpforlokit.hxx>
#include <tools/resmgr.hxx>
@@ -77,6 +78,7 @@
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
#include <vcl/ITiledRenderable.hxx>
+#include <unicode/uchar.h>
#include <unotools/configmgr.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx>
@@ -2056,6 +2058,58 @@ static char* getFonts (const char* pCommand)
return pJson;
}
+static char* getFontSubset (const OString& aFontName)
+{
+ OUString aFoundFont(::rtl::Uri::decode(OStringToOUString(aFontName, RTL_TEXTENCODING_UTF8), rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8));
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(
+ pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
+ const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
+
+ boost::property_tree::ptree aTree;
+ aTree.put("commandName", ".uno:FontSubset");
+ boost::property_tree::ptree aValues;
+
+ if ( pList && !aFoundFont.isEmpty() )
+ {
+ sal_uInt16 nFontCount = pList->GetFontNameCount();
+ sal_uInt16 nItFont = 0;
+ for (; nItFont < nFontCount; ++nItFont)
+ {
+ if (aFoundFont.equals(pList->GetFontName(nItFont).GetFamilyName()))
+ {
+ break;
+ }
+ }
+
+ if ( nItFont < nFontCount )
+ {
+ FontCharMapPtr pFontCharMap;
+ auto aDevice(VclPtr<VirtualDevice>::Create(nullptr, Size(1, 1), DeviceFormat::DEFAULT));
+ vcl::Font aFont(pList->GetFontName(nItFont));
+
+ aDevice->SetFont(aFont);
+ aDevice->GetFontCharMap(pFontCharMap);
+ SubsetMap aSubMap(pFontCharMap);
+
+ for(const Subset* pItSub = aSubMap.GetNextSubset(true); pItSub; pItSub = aSubMap.GetNextSubset(false))
+ {
+ boost::property_tree::ptree aChild;
+ aChild.put("", static_cast<int>(ublock_getCode(pItSub->GetRangeMin())));
+ aValues.push_back(std::make_pair("", aChild));
+ }
+ }
+ }
+
+ aTree.add_child("commandValues", aValues);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
+ strcpy(pJson, aStream.str().c_str());
+ pJson[aStream.str().size()] = '\0';
+ return pJson;
+}
+
static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
@@ -2265,6 +2319,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
OString aCommand(pCommand);
static const OString aViewRowColumnHeaders(".uno:ViewRowColumnHeaders");
static const OString aCellCursor(".uno:CellCursor");
+ static const OString aFontSubset(".uno:FontSubset&name=");
if (!strcmp(pCommand, ".uno:CharFontName"))
{
@@ -2395,6 +2450,10 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
strcpy(pMemory, aString.getStr());
return pMemory;
}
+ else if (aCommand.startsWith(aFontSubset))
+ {
+ return getFontSubset(OString(pCommand + aFontSubset.getLength()));
+ }
else
{
gImpl->maLastExceptionMsg = "Unknown command, no values returned";