21#include <officecfg/Office/Common.hxx>
25#include <sfx2/strings.hrc>
63 , m_xRecentCharView{
std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar1", m_aRecentCharView[0]),
64 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar2", m_aRecentCharView[1]),
65 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar3", m_aRecentCharView[2]),
66 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar4", m_aRecentCharView[3]),
67 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar5", m_aRecentCharView[4]),
68 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar6", m_aRecentCharView[5]),
69 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar7", m_aRecentCharView[6]),
70 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar8", m_aRecentCharView[7]),
71 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar9", m_aRecentCharView[8]),
72 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar10", m_aRecentCharView[9]),
73 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar11", m_aRecentCharView[10]),
74 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar12", m_aRecentCharView[11]),
75 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar13", m_aRecentCharView[12]),
76 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar14", m_aRecentCharView[13]),
77 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar15", m_aRecentCharView[14]),
78 std::make_unique<
weld::CustomWeld>(rBuilder,
"viewchar16", m_aRecentCharView[15])}
79 , m_xFavCharView{
std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar1", m_aFavCharView[0]),
80 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar2", m_aFavCharView[1]),
81 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar3", m_aFavCharView[2]),
82 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar4", m_aFavCharView[3]),
83 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar5", m_aFavCharView[4]),
84 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar6", m_aFavCharView[5]),
85 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar7", m_aFavCharView[6]),
86 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar8", m_aFavCharView[7]),
87 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar9", m_aFavCharView[8]),
88 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar10", m_aFavCharView[9]),
89 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar11", m_aFavCharView[10]),
90 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar12", m_aFavCharView[11]),
91 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar13", m_aFavCharView[12]),
92 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar14", m_aFavCharView[13]),
93 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar15", m_aFavCharView[14]),
94 std::make_unique<
weld::CustomWeld>(rBuilder,
"favchar16", m_aFavCharView[15])}
95 , m_xRecentGrid(rBuilder.weld_widget(
"viewgrid"))
96 , m_xFavGrid(rBuilder.weld_widget(
"favgrid"))
115 for(
int i = 0;
i < 16;
i++)
129 :
WeldToolbarPopup(pControl->getFrameInterface(), pParent,
"sfx/ui/charmapcontrol.ui",
"charmapctrl")
132 , m_aCharmapContents(*m_xBuilder, m_xVirDev)
133 , m_xRecentLabel(m_xBuilder->weld_label(
"label2"))
134 , m_xDlgBtn(m_xBuilder->weld_button(
"specialchardlg"))
152 const css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
156 const css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() );
196 const css::uno::Sequence< OUString > rRecentCharList( officecfg::Office::Common::RecentCharacters::RecentCharacterList::get() );
200 const css::uno::Sequence< OUString > rRecentCharFontList( officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::get() );
213 pView->InsertCharToDoc();
222 uno::Reference<frame::XFrame>
xFrame = pViewFrm->GetFrame().GetFrameInterface();
237static std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
238findInPair(std::u16string_view str1,
const std::deque<OUString>& rContainer1,
239 std::u16string_view str2,
const std::deque<OUString>& rContainer2)
241 assert(rContainer1.size() == rContainer2.size());
243 for (
auto it1 = std::find(rContainer1.begin(), rContainer1.end(), str1);
244 it1 != rContainer1.end(); it1 = std::find(std::next(it1), rContainer1.end(), str1))
246 auto it2 = rContainer2.begin() + (it1 - rContainer1.begin());
250 return { rContainer1.end(), rContainer2.end() };
253std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
259std::pair<std::deque<OUString>::const_iterator, std::deque<OUString>::const_iterator>
293 if(
const auto& [itChar, itChar2] =
getRecentChar(sTitle, rFont);
310 auto aRecentCharListRange = asNonConstRange(aRecentCharList);
312 auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList);
321 officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch);
322 officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch);
331 if(
const auto& [itChar, itChar2] =
getFavChar(sTitle, rFont);
347 css::uno::Sequence< OUString > aFavCharList(
m_aFavCharList.size());
348 auto aFavCharListRange = asNonConstRange(aFavCharList);
350 auto aFavCharFontListRange = asNonConstRange(aFavCharFontList);
359 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch);
360 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch);
367 if(
const auto& [itChar, itChar2] =
getFavChar(sTitle, rFont);
374 css::uno::Sequence< OUString > aFavCharList(
m_aFavCharList.size());
375 auto aFavCharListRange = asNonConstRange(aFavCharList);
377 auto aFavCharFontListRange = asNonConstRange(aFavCharFontList);
386 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch);
387 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch);
393 const auto& [itChar, itFont] =
getFavChar(sTitle, rFont);
399 const OUString& sTitle = rView->GetText();
400 OUString sFont = rView->GetFont().GetFamilyName();
403 if(
const auto& [itChar, itChar2] = getRecentChar(sTitle, sFont);
404 itChar != m_aRecentCharList.end() && itChar2 != m_aRecentCharFontList.end() )
406 m_aRecentCharList.erase( itChar );
407 m_aRecentCharFontList.erase( itChar2);
410 css::uno::Sequence< OUString > aRecentCharList(m_aRecentCharList.size());
411 auto aRecentCharListRange = asNonConstRange(aRecentCharList);
412 css::uno::Sequence< OUString > aRecentCharFontList(m_aRecentCharFontList.size());
413 auto aRecentCharFontListRange = asNonConstRange(aRecentCharFontList);
415 for (
size_t i = 0;
i < m_aRecentCharList.size(); ++
i)
417 aRecentCharListRange[
i] = m_aRecentCharList[
i];
418 aRecentCharFontListRange[
i] = m_aRecentCharFontList[
i];
422 officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch);
423 officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch);
426 updateRecentCharControl();
431 m_aRecentCharList.clear();
432 m_aRecentCharFontList.clear();
435 officecfg::Office::Common::RecentCharacters::RecentCharacterList::set({ }, batch);
436 officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set({ }, batch);
439 updateRecentCharControl();
444 deleteFavCharacterFromList(rView->GetText(), rView->GetFont().GetFamilyName());
445 updateFavCharControl();
450 m_aFavCharList.clear();
451 m_aFavCharFontList.clear();
454 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set({ }, batch);
455 officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set({ }, batch);
458 updateFavCharControl();
474 m_xRecentLabel->set_label(m_aCharmapContents.hasRecentChars() ?
SfxResId(STR_RECENT) :
SfxResId(STR_NORECENT));
IMPL_LINK(SfxCharmapCtrl, CharClickHdl, SvxCharView *, pView, void)
IMPL_LINK_NOARG(SfxCharmapCtrl, OpenDlgHdl, weld::Button &, void)
static std::pair< std::deque< OUString >::const_iterator, std::deque< OUString >::const_iterator > findInPair(std::u16string_view str1, const std::deque< OUString > &rContainer1, std::u16string_view str2, const std::deque< OUString > &rContainer2)
std::unique_ptr< weld::Widget > m_xRecentGrid
void updateRecentCharControl()
void updateRecentCharacterList(const OUString &sTitle, const OUString &rFont)
std::deque< OUString > m_aFavCharList
std::deque< OUString > m_aFavCharFontList
bool FavCharListIsFull() const
std::pair< std::deque< OUString >::const_iterator, std::deque< OUString >::const_iterator > getRecentChar(std::u16string_view sTitle, std::u16string_view rFont) const
std::unique_ptr< weld::Widget > m_xFavGrid
SfxCharmapContainer(weld::Builder &rBuilder, const VclPtr< VirtualDevice > &rVirDev)
void getRecentCharacterList()
void deleteFavCharacterFromList(std::u16string_view sTitle, std::u16string_view rFont)
std::pair< std::deque< OUString >::const_iterator, std::deque< OUString >::const_iterator > getFavChar(std::u16string_view sTitle, std::u16string_view rFont) const
bool isFavChar(std::u16string_view sTitle, std::u16string_view rFont)
SvxCharView m_aFavCharView[16]
Link< void *, void > m_aUpdateFavHdl
void GrabFocusToFirstFavorite()
void getFavCharacterList()
SvxCharView m_aRecentCharView[16]
std::deque< OUString > m_aRecentCharFontList
bool hasRecentChars() const
void updateFavCharacterList(const OUString &sTitle, const OUString &rFont)
void updateFavCharControl()
std::deque< OUString > m_aRecentCharList
Link< void *, void > m_aUpdateRecentHdl
void init(bool bHasInsert, const Link< SvxCharView *, void > &rMouseClickHdl, const Link< void *, void > &rUpdateFavHdl, const Link< void *, void > &rUpdateRecentHdl)
virtual void GrabFocus() override
std::unique_ptr< weld::Button > m_xDlgBtn
SfxCharmapCtrl(CharmapPopup *pControl, weld::Widget *pParent)
virtual ~SfxCharmapCtrl() override
SfxCharmapContainer m_aCharmapContents
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
vcl::Font const & GetFont() const
void setMouseClickHdl(const Link< SvxCharView *, void > &rLink)
void SetFont(const vcl::Font &rFont)
void SetHasInsert(bool bInsert)
void SetText(const OUString &rText)
void setClearClickHdl(const Link< SvxCharView *, void > &rLink)
void setClearAllClickHdl(const Link< SvxCharView *, void > &rLink)
static std::shared_ptr< ConfigurationChanges > create()
void SetFamilyName(const OUString &rFamilyName)
#define LINK(Instance, Class, Member)
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)
OUString SfxResId(TranslateId aId)
Reference< XFrame > xFrame