From 43d65d1ab81a278e1352f64def9ca63b9e7dfab9 Mon Sep 17 00:00:00 2001 From: Akshay Deep Date: Wed, 26 Jul 2017 11:30:35 +0530 Subject: Unicode Character Names Integration using ICU Change-Id: I0624690f8af05adb2466219a4e508e634c490ef1 Reviewed-on: https://gerrit.libreoffice.org/40436 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- cui/source/dialogs/cuicharmap.cxx | 28 ++++++++++++++++++++++++++++ cui/source/inc/cuicharmap.hxx | 3 +++ cui/uiconfig/ui/specialcharacters.ui | 16 ++++++++++++++++ 3 files changed, 47 insertions(+) (limited to 'cui') diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index 2b9fe879ab28..b2ac8ee93b9e 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -47,6 +47,8 @@ #include #include "strings.hrc" #include "macroass.hxx" +#include +#include using namespace css; @@ -71,6 +73,9 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, const SfxItemSet* pSet ) m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width()); get(m_pHexCodeText, "hexvalue"); get(m_pDecimalCodeText, "decimalvalue"); get(m_pFavouritesBtn, "favbtn"); + get(m_pCharName, "charname"); + m_pCharName->set_height_request(m_pCharName->GetTextHeight()*3); + m_pCharName->SetPaintTransparent(true); //lock the size request of this widget to the width of the original .ui string m_pHexCodeText->set_width_request(m_pHexCodeText->get_preferred_size().Width()); @@ -177,6 +182,7 @@ void SvxCharacterMap::dispose() m_pShowChar.clear(); m_pHexCodeText.clear(); m_pDecimalCodeText.clear(); + m_pCharName.clear(); maRecentCharList.clear(); maRecentCharFontList.clear(); @@ -498,6 +504,15 @@ void SvxCharacterMap::init() m_pFavCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl)); m_pFavCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl)); } + + char buffer[100]; + UErrorCode errorCode = U_ZERO_ERROR;; + + /* get the character name */ + u_charName((UChar32)90, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); + + if(U_SUCCESS(errorCode)) + m_pCharName->SetText(OUString::createFromAscii(buffer)); } bool SvxCharacterMap::isFavChar(const OUString& sTitle, const OUString& rFont) @@ -651,6 +666,17 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, ListBox&, void) m_pSubsetLB->Enable(bNeedSubset); } +void SvxCharacterMap::setCharName(char decimal[]) +{ + int nDecimalValue = std::stoi(decimal); + char buffer[100]; + UErrorCode errorCode; + + /* get the character name */ + errorCode=U_ZERO_ERROR; + u_charName((UChar32)nDecimalValue, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); + m_pCharName->SetText(OUString::createFromAscii(buffer)); +} IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, ListBox&, void) { @@ -765,6 +791,7 @@ IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void) m_pHexCodeText->SetText( aHexText ); m_pDecimalCodeText->SetText( aDecimalText ); + setCharName(aDecBuf); rView->Invalidate(); m_pOKBtn->Enable(); @@ -853,6 +880,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) char aDecBuf[32]; snprintf( aDecBuf, sizeof(aDecBuf), "%u", static_cast(cChar) ); aDecimalText = OUString::createFromAscii(aDecBuf); + setCharName(aDecBuf); } // Update the hex and decimal codes only if necessary diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index a79cd089177c..2681bb610ac4 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -81,6 +81,7 @@ private: VclPtr