Kaydet (Commit) 1b9956c2 authored tarafından Steve Hart's avatar Steve Hart Kaydeden (comit) Maxim Monastirsky

tdf#34882 Adding hex and decimal code search

Change-Id: I809bac4b28e679c7dad8ed3ad28e36379bce4760
üst 703f3f45
...@@ -63,9 +63,10 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, bool bOne_, const SfxIte ...@@ -63,9 +63,10 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, bool bOne_, const SfxIte
//lock the size request of this widget to the width of all possible entries //lock the size request of this widget to the width of all possible entries
fillAllSubsets(*m_pSubsetLB); fillAllSubsets(*m_pSubsetLB);
m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width()); m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width());
get(m_pCharCodeText, "charcodeft"); get(m_pHexCodeText, "hexvalue");
get(m_pDecimalCodeText, "decimalvalue");
//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_pCharCodeText->set_width_request(m_pCharCodeText->get_preferred_size().Width()); m_pHexCodeText->set_width_request(m_pHexCodeText->get_preferred_size().Width());
get(m_pSymbolText, "symboltext"); get(m_pSymbolText, "symboltext");
const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, FN_PARAM_1, false); const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, FN_PARAM_1, false);
...@@ -117,7 +118,8 @@ void SvxCharacterMap::dispose() ...@@ -117,7 +118,8 @@ void SvxCharacterMap::dispose()
m_pSubsetLB.clear(); m_pSubsetLB.clear();
m_pSymbolText.clear(); m_pSymbolText.clear();
m_pShowChar.clear(); m_pShowChar.clear();
m_pCharCodeText.clear(); m_pHexCodeText.clear();
m_pDecimalCodeText.clear();
SfxModalDialog::dispose(); SfxModalDialog::dispose();
} }
...@@ -368,6 +370,8 @@ void SvxCharacterMap::init() ...@@ -368,6 +370,8 @@ void SvxCharacterMap::init()
m_pShowSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) ); m_pShowSet->SetSelectHdl( LINK( this, SvxCharacterMap, CharSelectHdl ) );
m_pShowSet->SetHighlightHdl( LINK( this, SvxCharacterMap, CharHighlightHdl ) ); m_pShowSet->SetHighlightHdl( LINK( this, SvxCharacterMap, CharHighlightHdl ) );
m_pShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) ); m_pShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) );
m_pDecimalCodeText->SetModifyHdl( LINK( this, SvxCharacterMap, DecimalCodeChangeHdl ) );
m_pHexCodeText->SetModifyHdl( LINK( this, SvxCharacterMap, HexCodeChangeHdl ) );
if( SvxShowCharSet::getSelectedChar() == ' ') if( SvxShowCharSet::getSelectedChar() == ' ')
m_pOKBtn->Disable(); m_pOKBtn->Disable();
...@@ -538,6 +542,8 @@ IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharSelectHdl, SvxShowCharSet*, void) ...@@ -538,6 +542,8 @@ IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharSelectHdl, SvxShowCharSet*, void)
IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
{ {
OUString aText; OUString aText;
OUString aHexText;
OUString aDecimalText;
sal_UCS4 cChar = m_pShowSet->GetSelectCharacter(); sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
bool bSelect = (cChar > 0); bool bSelect = (cChar > 0);
...@@ -558,19 +564,57 @@ IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) ...@@ -558,19 +564,57 @@ IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
m_pShowChar->SetText( aText ); m_pShowChar->SetText( aText );
m_pShowChar->Update(); m_pShowChar->Update();
// show char code // show char codes
if ( bSelect ) if ( bSelect )
{ {
// Get the hexadecimal code
char aBuf[32]; char aBuf[32];
snprintf( aBuf, sizeof(aBuf), "U+%04X", static_cast<unsigned>(cChar) ); snprintf( aBuf, sizeof(aBuf), "%X", static_cast<unsigned>(cChar) );
if( cChar < 0x0100 ) aHexText = OUString::createFromAscii(aBuf);
snprintf( aBuf+6, sizeof(aBuf)-6, " (%u)", static_cast<unsigned>(cChar) ); // Get the decimal code
aText = OUString::createFromAscii(aBuf); char aDecBuf[32];
snprintf( aDecBuf, sizeof(aDecBuf), "%u", static_cast<unsigned>(cChar) );
aDecimalText = OUString::createFromAscii(aDecBuf);
} }
m_pCharCodeText->SetText( aText );
// Update the hex and decimal codes only if necessary
if (m_pHexCodeText->GetText() != aHexText)
m_pHexCodeText->SetText( aHexText );
if (m_pDecimalCodeText->GetText() != aDecimalText)
m_pDecimalCodeText->SetText( aDecimalText );
}
void SvxCharacterMap::selectCharByCode(Radix radix)
{
OUString aCodeString;
switch(radix)
{
case Radix::decimal:
aCodeString = m_pDecimalCodeText->GetText();
break;
case Radix::hexadecimal:
aCodeString = m_pHexCodeText->GetText();
break;
}
// Convert the code back to a character using the appropriate radix
sal_UCS4 cChar = aCodeString.toUInt32(static_cast<sal_Int16> (radix));
// Use FontCharMap::HasChar(sal_UCS4 cChar) to see if the desired character is in the font
FontCharMapPtr pFontCharMap(new FontCharMap());
m_pShowSet->GetFontCharMap(pFontCharMap);
if (pFontCharMap->HasChar(cChar))
// Select the corresponding character
SetChar(cChar);
} }
IMPL_LINK_NOARG_TYPED(SvxCharacterMap, DecimalCodeChangeHdl, Edit&, void)
{
selectCharByCode(Radix::decimal);
}
IMPL_LINK_NOARG_TYPED(SvxCharacterMap, HexCodeChangeHdl, Edit&, void)
{
selectCharByCode(Radix::hexadecimal);
}
IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharPreSelectHdl, SvxShowCharSet*, void) IMPL_LINK_NOARG_TYPED(SvxCharacterMap, CharPreSelectHdl, SvxShowCharSet*, void)
{ {
......
...@@ -76,10 +76,12 @@ private: ...@@ -76,10 +76,12 @@ private:
VclPtr<ListBox> m_pSubsetLB; VclPtr<ListBox> m_pSubsetLB;
VclPtr<FixedText> m_pSymbolText; VclPtr<FixedText> m_pSymbolText;
VclPtr<SvxShowText> m_pShowChar; VclPtr<SvxShowText> m_pShowChar;
VclPtr<FixedText> m_pCharCodeText; VclPtr<Edit> m_pHexCodeText;
VclPtr<Edit> m_pDecimalCodeText;
vcl::Font aFont; vcl::Font aFont;
bool bOne; bool bOne;
const SubsetMap* pSubsetMap; const SubsetMap* pSubsetMap;
enum class Radix : sal_Int16 {decimal = 10, hexadecimal=16};
DECL_LINK_TYPED(OKHdl, Button*, void); DECL_LINK_TYPED(OKHdl, Button*, void);
DECL_LINK_TYPED(FontSelectHdl, ListBox&, void); DECL_LINK_TYPED(FontSelectHdl, ListBox&, void);
...@@ -88,8 +90,11 @@ private: ...@@ -88,8 +90,11 @@ private:
DECL_LINK_TYPED(CharSelectHdl, SvxShowCharSet*, void); DECL_LINK_TYPED(CharSelectHdl, SvxShowCharSet*, void);
DECL_LINK_TYPED(CharHighlightHdl, SvxShowCharSet*, void); DECL_LINK_TYPED(CharHighlightHdl, SvxShowCharSet*, void);
DECL_LINK_TYPED(CharPreSelectHdl, SvxShowCharSet*, void); DECL_LINK_TYPED(CharPreSelectHdl, SvxShowCharSet*, void);
DECL_LINK_TYPED(DecimalCodeChangeHdl, Edit&, void);
DECL_LINK_TYPED(HexCodeChangeHdl, Edit&, void);
static void fillAllSubsets(ListBox &rListBox); static void fillAllSubsets(ListBox &rListBox);
void selectCharByCode(Radix radix);
public: public:
SvxCharacterMap( vcl::Window* pParent, bool bOne=true, const SfxItemSet* pSet=nullptr ); SvxCharacterMap( vcl::Window* pParent, bool bOne=true, const SfxItemSet* pSet=nullptr );
......
...@@ -199,24 +199,113 @@ ...@@ -199,24 +199,113 @@
<property name="vexpand">True</property> <property name="vexpand">True</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>
<property name="height_request">150</property> <property name="height_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="decimallabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="label" translatable="yes">Decimal:</property>
<property name="vexpand">True</property>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="decimalvalue">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text">162</property>
<property name="halign">center</property>
<property name="width_chars">11</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="charcodeft"> <object class="GtkBox" id="box3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="orientation">vertical</property>
<property name="label" translatable="no"> U+FFFF(65535) </property> <child>
<object class="GtkLabel" id="hexlabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hexadecimal:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkLabel" id="hexulabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">U+</property>
<property name="selectable">True</property>
<property name="width_chars">3</property>
<property name="single_line_mode">True</property>
<property name="max_width_chars">3</property>
<property name="lines">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="hexvalue">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text">A2</property>
<property name="halign">center</property>
<property name="width_chars">8</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
......
...@@ -804,5 +804,8 @@ ...@@ -804,5 +804,8 @@
<glade-widget-class title="Ruby RadioButton" name="cuilo-RubyRadioButton" <glade-widget-class title="Ruby RadioButton" name="cuilo-RubyRadioButton"
generic-name="RubyRadioButton" parent="GtkRadioButton" generic-name="RubyRadioButton" parent="GtkRadioButton"
icon-name="widget-gtk-radiobutton"/> icon-name="widget-gtk-radiobutton"/>
<glade-widget-class title="Show Text" name="cuilo-SvxShowText"
generic-name="ShowText" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
</glade-widget-classes> </glade-widget-classes>
</glade-catalog> </glade-catalog>
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