summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorAkshay Deep <akshaydeepiitr@gmail.com>2017-07-20 19:08:28 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-07-25 21:26:39 +0200
commit06aacee86ec9e53928cc0c31906a8922babfe2b6 (patch)
treec0559e52b5c3b599f18b5b0fa5bdbaf07b161981 /cui
parent987f8824b4f229590b54b11482da431d451412f1 (diff)
Clear Recent View and Fav view using Right Click
Conflicts: sfx2/inc/doc.hrc sfx2/source/doc/doc.src Change-Id: I0aa2919815a3fa63ee180b808834a8aa760af649 Reviewed-on: https://gerrit.libreoffice.org/40234 Reviewed-by: Akshay Deep <akshaydeepiitr@gmail.com> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/cuicharmap.cxx79
-rw-r--r--cui/source/inc/cuicharmap.hxx4
2 files changed, 83 insertions, 0 deletions
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 500f0143e3ef..2b9fe879ab28 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -490,8 +490,12 @@ void SvxCharacterMap::init()
for(int i = 0; i < 16; i++)
{
m_pRecentCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
+ m_pRecentCharView[i]->setClearClickHdl(LINK(this,SvxCharacterMap, RecentClearClickHdl));
+ m_pRecentCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, RecentClearAllClickHdl));
m_pRecentCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl));
m_pFavCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
+ m_pFavCharView[i]->setClearClickHdl(LINK(this,SvxCharacterMap, FavClearClickHdl));
+ m_pFavCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl));
m_pFavCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl));
}
}
@@ -662,6 +666,81 @@ IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, ListBox&, void)
m_pSubsetLB->SelectEntryPos( nPos );
}
+IMPL_LINK(SvxCharacterMap, RecentClearClickHdl, SvxCharView*, rView, void)
+{
+ OUString sTitle = rView->GetText();
+ auto itChar = std::find_if(maRecentCharList.begin(),
+ maRecentCharList.end(),
+ [sTitle] (const OUString & a) { return a == sTitle; });
+
+ OUString sFont = rView->GetFont().GetFamilyName();
+ auto itChar2 = std::find_if(maRecentCharFontList.begin(),
+ maRecentCharFontList.end(),
+ [sFont] (const OUString & a)
+ { return a == sFont; });
+
+ // if recent char to be added is already in list, remove it
+ if( itChar != maRecentCharList.end() && itChar2 != maRecentCharFontList.end() )
+ {
+ maRecentCharList.erase( itChar );
+ maRecentCharFontList.erase( itChar2);
+ }
+
+ css::uno::Sequence< OUString > aRecentCharList(maRecentCharList.size());
+ css::uno::Sequence< OUString > aRecentCharFontList(maRecentCharFontList.size());
+
+ for (size_t i = 0; i < maRecentCharList.size(); ++i)
+ {
+ aRecentCharList[i] = maRecentCharList[i];
+ aRecentCharFontList[i] = maRecentCharFontList[i];
+ }
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext));
+ officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch);
+ officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch);
+ batch->commit();
+
+ updateRecentCharControl();
+}
+
+IMPL_LINK_NOARG(SvxCharacterMap, RecentClearAllClickHdl, SvxCharView*, void)
+{
+ css::uno::Sequence< OUString > aRecentCharList(0);
+ css::uno::Sequence< OUString > aRecentCharFontList(0);
+
+ maRecentCharList.clear();
+ maRecentCharFontList.clear();
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext));
+ officecfg::Office::Common::RecentCharacters::RecentCharacterList::set(aRecentCharList, batch);
+ officecfg::Office::Common::RecentCharacters::RecentCharacterFontList::set(aRecentCharFontList, batch);
+ batch->commit();
+
+ updateRecentCharControl();
+}
+
+IMPL_LINK(SvxCharacterMap, FavClearClickHdl, SvxCharView*, rView, void)
+{
+ deleteFavCharacterFromList(rView->GetText(), rView->GetFont().GetFamilyName());
+ updateFavCharControl();
+}
+
+IMPL_LINK_NOARG(SvxCharacterMap, FavClearAllClickHdl, SvxCharView*, void)
+{
+ css::uno::Sequence< OUString > aFavCharList(0);
+ css::uno::Sequence< OUString > aFavCharFontList(0);
+
+ maFavCharList.clear();
+ maFavCharFontList.clear();
+
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(mxContext));
+ officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::set(aFavCharList, batch);
+ officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::set(aFavCharFontList, batch);
+ batch->commit();
+
+ updateFavCharControl();
+}
+
IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void)
{
m_pShowChar->SetText( rView->GetText() );
diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx
index ecf3d2cb709f..a79cd089177c 100644
--- a/cui/source/inc/cuicharmap.hxx
+++ b/cui/source/inc/cuicharmap.hxx
@@ -104,6 +104,10 @@ private:
DECL_LINK(DecimalCodeChangeHdl, Edit&, void);
DECL_LINK(HexCodeChangeHdl, Edit&, void);
DECL_LINK(CharClickHdl, SvxCharView*, void);
+ DECL_LINK(RecentClearClickHdl, SvxCharView*, void);
+ DECL_LINK(FavClearClickHdl, SvxCharView*, void);
+ DECL_LINK(RecentClearAllClickHdl, SvxCharView*, void);
+ DECL_LINK(FavClearAllClickHdl, SvxCharView*, void);
DECL_LINK(InsertClickHdl, Button*, void);
DECL_STATIC_LINK(SvxCharacterMap, LoseFocusHdl, Control&, void);
DECL_LINK(FavSelectHdl, Button*, void);