summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Deep <akshaydeepiitr@gmail.com>2017-07-26 11:30:35 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-07-28 12:24:57 +0200
commit43d65d1ab81a278e1352f64def9ca63b9e7dfab9 (patch)
tree2a335cc315d1f18891cf33f3d4fae4d0a4e9a0b4
parent192d97cdf091af08a492416824918ea447bfb16f (diff)
Unicode Character Names Integration using ICU
Change-Id: I0624690f8af05adb2466219a4e508e634c490ef1 Reviewed-on: https://gerrit.libreoffice.org/40436 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--cui/source/dialogs/cuicharmap.cxx28
-rw-r--r--cui/source/inc/cuicharmap.hxx3
-rw-r--r--cui/uiconfig/ui/specialcharacters.ui16
3 files changed, 47 insertions, 0 deletions
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 <editeng/fontitem.hxx>
#include "strings.hrc"
#include "macroass.hxx"
+#include <unicode/uchar.h>
+#include <unicode/utypes.h>
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<unsigned>(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<Button> m_pFavouritesBtn;
VclPtr<SvxCharView> m_pRecentCharView[16];
VclPtr<SvxCharView> m_pFavCharView[16];
+ VclPtr<VclMultiLineEdit> m_pCharName;
vcl::Font aFont;
const SubsetMap* pSubsetMap;
@@ -142,6 +143,8 @@ public:
void updateFavCharControl();
void setFavButtonState(const OUString& sTitle, const OUString& rFont);
+
+ void setCharName(char decimal[]);
};
#endif
diff --git a/cui/uiconfig/ui/specialcharacters.ui b/cui/uiconfig/ui/specialcharacters.ui
index 967411134d3f..15104d2f27b0 100644
--- a/cui/uiconfig/ui/specialcharacters.ui
+++ b/cui/uiconfig/ui/specialcharacters.ui
@@ -160,6 +160,7 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="row_spacing">6</property>
<child>
<object class="cuilo-SvxShowText" id="showchar">
<property name="width_request">80</property>
@@ -178,6 +179,7 @@
<object class="GtkGrid" id="grid4">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="halign">center</property>
<property name="row_spacing">3</property>
<property name="column_spacing">6</property>
<property name="row_homogeneous">True</property>
@@ -275,6 +277,20 @@
</object>
<packing>
<property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="charname">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="editable">False</property>
+ <property name="wrap_mode">word</property>
+ <property name="justification">center</property>
+ <property name="cursor_visible">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>