30#include <rtl/textenc.h>
37#include <officecfg/Office/Common.hxx>
38#include <com/sun/star/beans/PropertyValue.hpp>
46#include <svx/svxids.hrc>
47#include <editeng/editids.hrc>
50#include <unicode/uchar.h>
51#include <unicode/utypes.h>
56 css::uno::Reference<css::frame::XFrame> xFrame)
61 , m_aCharmapContents(*m_xBuilder, m_xVirDev)
62 , m_aShowChar(m_xVirDev)
63 , m_xOKBtn(
m_xFrame.is() ? m_xBuilder->weld_button(
"insert") : m_xBuilder->weld_button(
"ok"))
64 , m_xFontText(m_xBuilder->weld_label(
"fontft"))
65 , m_xFontLB(m_xBuilder->weld_combo_box(
"fontlb"))
66 , m_xSubsetText(m_xBuilder->weld_label(
"subsetft"))
67 , m_xSubsetLB(m_xBuilder->weld_combo_box(
"subsetlb"))
68 , m_xSearchText(m_xBuilder->weld_entry(
"search"))
69 , m_xHexCodeText(m_xBuilder->weld_entry(
"hexvalue"))
70 , m_xDecimalCodeText(m_xBuilder->weld_entry(
"decimalvalue"))
71 , m_xFavouritesBtn(m_xBuilder->weld_button(
"favbtn"))
72 , m_xCharName(m_xBuilder->weld_label(
"charname"))
73 , m_xShowChar(new
weld::CustomWeld(*m_xBuilder,
"showchar", m_aShowChar))
74 , m_xShowSet(new
SvxShowCharSet(m_xBuilder->weld_scrolled_window(
"showscroll", true), m_xVirDev))
75 , m_xShowSetArea(new
weld::CustomWeld(*m_xBuilder,
"showcharset", *m_xShowSet))
76 , m_xSearchSet(new
SvxSearchCharSet(m_xBuilder->weld_scrolled_window(
"searchscroll", true), m_xVirDev))
77 , m_xSearchSetArea(new
weld::CustomWeld(*m_xBuilder,
"searchcharset", *m_xSearchSet))
90 const SfxInt32Item* pCharItem = SfxItemSet::GetItem<SfxInt32Item>(pSet, SID_ATTR_CHAR,
false);
94 const SfxBoolItem* pDisableItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, FN_PARAM_2,
false);
95 if ( pDisableItem && pDisableItem->
GetValue() )
98 const SvxFontItem* pFontItem = SfxItemSet::GetItem<SvxFontItem>(pSet, SID_ATTR_CHAR_FONT,
false);
99 const SfxStringItem* pFontNameItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_FONT_NAME,
false);
107 else if ( pFontNameItem )
130 OUString aOUStr( &cChar, 1 );
137 return SfxDialogController::run();
159 m_xShowSet->getFavCharacterList();
160 m_xSearchSet->getFavCharacterList();
162 m_xShowSet->Invalidate();
176 std::vector<weld::ComboBoxEntry>
aEntries;
180 OUString aFontName(
m_xVirDev->GetFontMetricFromCollection(
i ).GetFamilyName() );
181 if (aFontName != aLastName)
183 aLastName = aFontName;
184 aEntries.emplace_back(aFontName, OUString::number(
i));
191 bool bFound = (
m_xFontLB->find_text(aDefStr) != -1);
197 OUString aToken = aDefStr.getToken(0,
';',
nIndex);
244 nMaxWidth = std::max(nMaxWidth,
m_xFavouritesBtn->get_preferred_size().Width());
255 OUString aOUStr( &cChar, 1 );
275 if(sTitle.empty() || rFont.empty())
305 if (
const sal_Int32
nIndex = sFontFamilyName.indexOf(
":");
nIndex != -1)
306 sFontFamilyName = sFontFamilyName.copy(0,
nIndex);
307 if (sFontFamilyName ==
"StarSymbol" &&
m_xFontLB->find_text(sFontFamilyName) == -1)
314 if (
m_xFontLB->find_text(sFontFamilyName) == -1)
317 m_xFontLB->set_active_text(sFontFamilyName);
327 std::vector<weld::ComboBoxEntry>
aEntries;
329 aEntries.emplace_back(subset.GetName());
360 const sal_uInt32 nFont = m_xFontLB->get_active_id().toUInt32();
361 aFont = m_xVirDev->GetFontMetricFromCollection(nFont);
369 m_xShowSet->SetFont( aFont );
370 m_xSearchSet->SetFont( aFont );
371 m_aShowChar.SetFont( aFont );
377 m_xSubsetLB->clear();
379 bool bNeedSubset = (aFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL);
383 pSubsetMap.reset(
new SubsetMap( xFontCharMap ));
386 for (
auto const& subset : pSubsetMap->GetSubsetMap())
388 m_xSubsetLB->append(
weld::toId(&subset), subset.GetName());
392 if (m_xSubsetLB->get_count() <= 1)
396 m_xSubsetText->set_sensitive(bNeedSubset);
397 m_xSubsetLB->set_sensitive(bNeedSubset);
403 SearchUpdateHdl(*m_xSearchText);
404 SearchCharHighlightHdl(m_xSearchSet.get());
408 selectCharByCode(Radix::hexadecimal);
433 UErrorCode errorCode = U_ZERO_ERROR;
437 u_charName(nDecimalValue, U_UNICODE_CHAR_NAME, buffer,
sizeof(buffer), &errorCode);
438 if (U_SUCCESS(errorCode))
439 m_xCharName->set_label(OUString::createFromAscii(buffer));
444 const sal_Int32
nPos = m_xSubsetLB->get_active();
445 const Subset* pSubset = weld::fromId<const Subset*>(m_xSubsetLB->get_active_id());
447 if( pSubset && !isSearchMode)
450 m_xShowSet->SelectCharacter( cFirst );
452 setFavButtonState(OUString(&cFirst, 1), aFont.GetFamilyName());
453 m_xSubsetLB->set_active(
nPos);
455 else if( pSubset && isSearchMode)
457 m_xSearchSet->SelectCharacter( pSubset );
459 const Subset* curSubset =
nullptr;
461 curSubset = pSubsetMap->GetSubsetByUnicode( m_xSearchSet->GetSelectCharacter() );
463 m_xSubsetLB->set_active_text(curSubset->
GetName());
465 m_xSubsetLB->set_active(-1);
467 sal_UCS4 sChar = m_xSearchSet->GetSelectCharacter();
468 setFavButtonState(OUString(&sChar, 1), aFont.GetFamilyName());
474 m_xOKBtn->set_sensitive(
false);
479 if (!m_xSearchText->get_text().isEmpty())
481 m_xSearchSet->ClearPreviousData();
482 OUString aKeyword = m_xSearchText->get_text();
484 toggleSearchView(
true);
488 sal_UCS4 sChar = xFontCharMap->GetFirstChar();
489 while(sChar != xFontCharMap->GetLastChar())
491 UErrorCode errorCode = U_ZERO_ERROR;
493 u_charName(sChar, U_UNICODE_CHAR_NAME, buffer,
sizeof(buffer), &errorCode);
494 if (U_SUCCESS(errorCode))
496 OUString
sName = OUString::createFromAscii(buffer);
497 if(!
sName.isEmpty() &&
sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0)
498 m_xSearchSet->AppendCharToList(sChar);
500 sChar = xFontCharMap->GetNextChar(sChar);
503 UErrorCode errorCode = U_ZERO_ERROR;
505 u_charName(sChar, U_UNICODE_CHAR_NAME, buffer,
sizeof(buffer), &errorCode);
506 if (U_SUCCESS(errorCode))
508 OUString
sName = OUString::createFromAscii(buffer);
509 if(!
sName.isEmpty() &&
sName.toAsciiLowerCase().indexOf(aKeyword.toAsciiLowerCase()) >= 0)
510 m_xSearchSet->AppendCharToList(sChar);
513 m_xSearchSet->UpdateScrollRange();
517 toggleSearchView(
false);
526 m_aShowChar.SetText( rView->GetText() );
527 m_aShowChar.SetFont(rView->GetFont());
528 m_aShowChar.Invalidate();
530 setFavButtonState(rView->GetText(), rView->GetFont().GetFamilyName());
533 OUString charValue = rView->GetText();
535 OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
538 OUString aDecimalText = OUString::number(cChar);
540 m_xHexCodeText->set_text(aHexText);
541 m_xDecimalCodeText->set_text(aDecimalText);
545 m_xOKBtn->set_sensitive(
true);
553 OUString aOUStr( &cChar, 1 );
560 insertSelectedCharacter(pCharSet);
565 m_xOKBtn->set_sensitive(
true);
570 insertSelectedCharacter(pCharSet);
576 OUString sChar = m_aShowChar.GetText();
577 insertCharToDoc(sChar);
580 m_aCharmapContents.updateRecentCharacterList(sChar, aFont.GetFamilyName());
586 if (m_xFavouritesBtn->get_label().match(
CuiResId(RID_CUISTR_ADD_FAVORITES)))
588 m_aCharmapContents.updateFavCharacterList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName());
589 setFavButtonState(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName());
593 m_aCharmapContents.deleteFavCharacterFromList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName());
594 m_xFavouritesBtn->set_label(
CuiResId(RID_CUISTR_ADD_FAVORITES));
595 m_xFavouritesBtn->set_sensitive(
false);
598 m_aCharmapContents.updateFavCharControl();
603 m_aCharmapContents.getFavCharacterList();
604 m_aCharmapContents.updateFavCharControl();
610 sal_UCS4 cChar = m_xShowSet->GetSelectCharacter();
611 bool bSelect = (cChar > 0);
617 aText = OUString( &cChar, 1 );
619 OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
621 OUString aDecimalText = OUString::number(cChar);
625 if (!m_xHexCodeText->get_text().equalsIgnoreAsciiCase(aHexText))
626 m_xHexCodeText->set_text(aHexText);
627 if (m_xDecimalCodeText->get_text() != aDecimalText)
628 m_xDecimalCodeText->set_text( aDecimalText );
630 const Subset* pSubset =
nullptr;
632 pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
634 m_xSubsetLB->set_active_text(pSubset->
GetName());
636 m_xSubsetLB->set_active(-1);
639 m_aShowChar.SetText( aText );
640 m_aShowChar.SetFont( aFont );
641 m_aShowChar.Invalidate();
643 setFavButtonState(aText, aFont.GetFamilyName());
649 sal_UCS4 cChar = m_xSearchSet->GetSelectCharacter();
650 bool bSelect = (cChar > 0);
655 aText = OUString( &cChar, 1 );
657 OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
659 OUString aDecimalText = OUString::number(cChar);
663 if (!m_xHexCodeText->get_text().equalsIgnoreAsciiCase(aHexText))
664 m_xHexCodeText->set_text(aHexText);
665 if (m_xDecimalCodeText->get_text() != aDecimalText)
666 m_xDecimalCodeText->set_text( aDecimalText );
668 const Subset* pSubset =
nullptr;
670 pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
672 m_xSubsetLB->set_active_text(pSubset->
GetName());
674 m_xSubsetLB->set_active(-1);
677 if(m_xSearchSet->HasFocus())
679 m_aShowChar.SetText( aText );
680 m_aShowChar.SetFont( aFont );
681 m_aShowChar.Invalidate();
683 setFavButtonState(aText, aFont.GetFamilyName());
689 OUString aCodeString;
700 sal_UCS4 cChar = aCodeString.toUInt32(
static_cast<sal_Int16
> (radix));
703 if (xFontCharMap->HasChar(cChar))
723 selectCharByCode(Radix::decimal);
728 selectCharByCode(Radix::hexadecimal);
737 sal_UCS4 cChar = pCharSet->GetSelectCharacter();
739 setFavButtonState(OUString(&cChar, 1), aFont.GetFamilyName());
740 const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
742 m_xSubsetLB->set_active_text(pSubset->
GetName());
745 m_xOKBtn->set_sensitive(
true);
758 CustomWidgetController::SetDrawingArea(pDrawingArea);
765 m_xVirDev->LogicToPixel(aFontSize).Height() * 2);
784 const OUString aText =
GetText();
790 bool bGotBoundary =
true;
791 bool bShrankFont =
false;
796 for (
tools::Long nFontHeight = aFontSize.
Height(); nFontHeight > 0; nFontHeight -= 5)
800 bGotBoundary =
false;
807 if (nAvailWidth > nTextWidth)
824 aBoundRect += aPoint;
827 int nYLDelta = aBoundRect.
Top();
830 aPoint.
AdjustY( -(nYLDelta - 1) );
831 else if( nYHDelta <= 0 )
842 int nXLDelta = aBoundRect.
Left();
843 int nXHDelta = aSize.
Width() - aBoundRect.
Right();
845 aPoint.
AdjustX( -(nXLDelta - 1) );
846 else if( nXHDelta <= 0 )
853 rRenderContext.
DrawText(aPoint, aText);
858 rRenderContext.
SetFont(aOrigFont);
css::uno::Reference< css::lang::XComponent > m_xFrame
SfxApplication * SfxGetpApp()
Reference< XExecutableDialog > m_xDialog
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
sal_Int32 GetValue() const
const OUString & GetValue() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
const Color & GetLineColor() const
const Color & GetTextColor() const
tools::Long GetTextHeight() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() const
void setX(tools::Long nX)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
void updateRecentCharacterList(const OUString &sTitle, const OUString &rFont)
bool FavCharListIsFull() const
bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont)
void init(bool bHasInsert, const Link< SvxCharView *, void > &rMouseClickHdl, const Link< void *, void > &rUpdateFavHdl, const Link< void *, void > &rUpdateRecentHdl)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
SfxItemPool * GetPool() const
constexpr tools::Long Height() const
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetWindowColor() const
const Color & GetDialogTextColor() const
const Color & GetShadowColor() const
const SubsetVec & GetSubsetMap() const
sal_UCS4 GetRangeMin() const
const OUString & GetName() const
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
void toggleSearchView(bool state)
std::unique_ptr< SvxShowCharSet > m_xShowSet
std::unique_ptr< weld::Label > m_xFontText
std::unique_ptr< weld::Entry > m_xDecimalCodeText
void insertSelectedCharacter(const SvxShowCharSet *pCharSet)
void DisableFontSelection()
ScopedVclPtr< VirtualDevice > m_xVirDev
std::unique_ptr< weld::ComboBox > m_xFontLB
std::unique_ptr< weld::Entry > m_xHexCodeText
virtual short run() override
std::unique_ptr< weld::Label > m_xCharName
const vcl::Font & GetCharFont() const
void selectCharByCode(Radix radix)
std::unique_ptr< SvxSearchCharSet > m_xSearchSet
std::unique_ptr< weld::ComboBox > m_xSubsetLB
void setCharName(sal_UCS4 nDecimalValue)
void setFavButtonState(std::u16string_view sTitle, std::u16string_view rFont)
std::unique_ptr< weld::Button > m_xOKBtn
void insertCharToDoc(const OUString &sChar)
void SetCharFont(const vcl::Font &rFont)
SfxCharmapContainer m_aCharmapContents
css::uno::Reference< css::frame::XFrame > m_xFrame
SvxCharacterMap(weld::Widget *pParent, const SfxItemSet *pSet, css::uno::Reference< css::frame::XFrame > xFrame)
std::unique_ptr< weld::Entry > m_xSearchText
std::unique_ptr< weld::Button > m_xFavouritesBtn
std::unique_ptr< SfxAllItemSet > m_xOutputSet
static void fillAllSubsets(weld::ComboBox &rListBox)
FontPitch GetPitch() const
const OUString & GetStyleName() const
rtl_TextEncoding GetCharSet() const
const OUString & GetFamilyName() const
static sal_uInt32 & getSelectedChar()
virtual sal_UCS4 GetSelectCharacter() const
SvxShowText(const VclPtr< VirtualDevice > &rVirDev)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Size get_preferred_size() const
void SetFont(const vcl::Font &rFont)
virtual void Resize() override
ScopedVclPtr< VirtualDevice > m_xVirDev
vcl::Font const & GetFont() const
void SetText(const OUString &rText)
OUString const & GetText() const
void SetCentered(bool bCenter)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetFontSize(const Size &)
FontFamily GetFamilyType()
void SetPitch(FontPitch ePitch)
void SetTransparent(bool bTransparent)
const OUString & GetStyleName() const
void SetWeight(FontWeight)
const OUString & GetFamilyName() const
void SetFamily(FontFamily)
void SetCharSet(rtl_TextEncoding)
const Size & GetFontSize() const
void SetAlignment(TextAlign)
void SetFamilyName(const OUString &rFamilyName)
rtl_TextEncoding GetCharSet() const
virtual void insert_vector(const std::vector< weld::ComboBoxEntry > &rItems, bool bKeepExisting)=0
IMPL_LINK_NOARG(SvxCharacterMap, UpdateFavHdl, void *, void)
IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView *, rView, void)
OUString CuiResId(TranslateId aKey)
ScXMLEditAttributeMap::Entry const aEntries[]
#define LINK(Instance, Class, Member)
sal_uInt16 GetFontSize(sal_uInt16 nPos)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr T & temporary(T &&x)
OUString toId(const void *pValue)
Reference< XFrame > xFrame