Kaydet (Commit) 43d65d1a authored tarafından Akshay Deep's avatar Akshay Deep Kaydeden (comit) Samuel Mehrbrodt

Unicode Character Names Integration using ICU

Change-Id: I0624690f8af05adb2466219a4e508e634c490ef1
Reviewed-on: https://gerrit.libreoffice.org/40436Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 192d97cd
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#include <editeng/fontitem.hxx> #include <editeng/fontitem.hxx>
#include "strings.hrc" #include "strings.hrc"
#include "macroass.hxx" #include "macroass.hxx"
#include <unicode/uchar.h>
#include <unicode/utypes.h>
using namespace css; using namespace css;
...@@ -71,6 +73,9 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, const SfxItemSet* pSet ) ...@@ -71,6 +73,9 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, const SfxItemSet* pSet )
m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width()); m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width());
get(m_pHexCodeText, "hexvalue"); get(m_pDecimalCodeText, "decimalvalue"); get(m_pHexCodeText, "hexvalue"); get(m_pDecimalCodeText, "decimalvalue");
get(m_pFavouritesBtn, "favbtn"); 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 //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()); m_pHexCodeText->set_width_request(m_pHexCodeText->get_preferred_size().Width());
...@@ -177,6 +182,7 @@ void SvxCharacterMap::dispose() ...@@ -177,6 +182,7 @@ void SvxCharacterMap::dispose()
m_pShowChar.clear(); m_pShowChar.clear();
m_pHexCodeText.clear(); m_pHexCodeText.clear();
m_pDecimalCodeText.clear(); m_pDecimalCodeText.clear();
m_pCharName.clear();
maRecentCharList.clear(); maRecentCharList.clear();
maRecentCharFontList.clear(); maRecentCharFontList.clear();
...@@ -498,6 +504,15 @@ void SvxCharacterMap::init() ...@@ -498,6 +504,15 @@ void SvxCharacterMap::init()
m_pFavCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl)); m_pFavCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl));
m_pFavCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl)); 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) bool SvxCharacterMap::isFavChar(const OUString& sTitle, const OUString& rFont)
...@@ -651,6 +666,17 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, ListBox&, void) ...@@ -651,6 +666,17 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, ListBox&, void)
m_pSubsetLB->Enable(bNeedSubset); 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) IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, ListBox&, void)
{ {
...@@ -765,6 +791,7 @@ IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void) ...@@ -765,6 +791,7 @@ IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void)
m_pHexCodeText->SetText( aHexText ); m_pHexCodeText->SetText( aHexText );
m_pDecimalCodeText->SetText( aDecimalText ); m_pDecimalCodeText->SetText( aDecimalText );
setCharName(aDecBuf);
rView->Invalidate(); rView->Invalidate();
m_pOKBtn->Enable(); m_pOKBtn->Enable();
...@@ -853,6 +880,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) ...@@ -853,6 +880,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
char aDecBuf[32]; char aDecBuf[32];
snprintf( aDecBuf, sizeof(aDecBuf), "%u", static_cast<unsigned>(cChar) ); snprintf( aDecBuf, sizeof(aDecBuf), "%u", static_cast<unsigned>(cChar) );
aDecimalText = OUString::createFromAscii(aDecBuf); aDecimalText = OUString::createFromAscii(aDecBuf);
setCharName(aDecBuf);
} }
// Update the hex and decimal codes only if necessary // Update the hex and decimal codes only if necessary
......
...@@ -81,6 +81,7 @@ private: ...@@ -81,6 +81,7 @@ private:
VclPtr<Button> m_pFavouritesBtn; VclPtr<Button> m_pFavouritesBtn;
VclPtr<SvxCharView> m_pRecentCharView[16]; VclPtr<SvxCharView> m_pRecentCharView[16];
VclPtr<SvxCharView> m_pFavCharView[16]; VclPtr<SvxCharView> m_pFavCharView[16];
VclPtr<VclMultiLineEdit> m_pCharName;
vcl::Font aFont; vcl::Font aFont;
const SubsetMap* pSubsetMap; const SubsetMap* pSubsetMap;
...@@ -142,6 +143,8 @@ public: ...@@ -142,6 +143,8 @@ public:
void updateFavCharControl(); void updateFavCharControl();
void setFavButtonState(const OUString& sTitle, const OUString& rFont); void setFavButtonState(const OUString& sTitle, const OUString& rFont);
void setCharName(char decimal[]);
}; };
#endif #endif
......
...@@ -160,6 +160,7 @@ ...@@ -160,6 +160,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="row_spacing">6</property>
<child> <child>
<object class="cuilo-SvxShowText" id="showchar"> <object class="cuilo-SvxShowText" id="showchar">
<property name="width_request">80</property> <property name="width_request">80</property>
...@@ -178,6 +179,7 @@ ...@@ -178,6 +179,7 @@
<object class="GtkGrid" id="grid4"> <object class="GtkGrid" id="grid4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">center</property>
<property name="row_spacing">3</property> <property name="row_spacing">3</property>
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<property name="row_homogeneous">True</property> <property name="row_homogeneous">True</property>
...@@ -273,6 +275,20 @@ ...@@ -273,6 +275,20 @@
</packing> </packing>
</child> </child>
</object> </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> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment