[Libreoffice-commits] core.git: cui/source cui/uiconfig include/sfx2 officecfg/registry sfx2/source sfx2/uiconfig

Akshay Deep akshaydeepiitr at gmail.com
Wed Jul 19 08:16:27 UTC 2017


 cui/source/dialogs/cuicharmap.cxx                          |  223 ++++++++++
 cui/source/dialogs/cuires.src                              |   10 
 cui/source/inc/cuicharmap.hxx                              |   17 
 cui/source/inc/cuires.hrc                                  |    2 
 cui/uiconfig/ui/specialcharacters.ui                       |  279 +++++++++++--
 include/sfx2/charmapcontrol.hxx                            |    8 
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |   17 
 sfx2/source/control/charmapcontrol.cxx                     |   67 +++
 sfx2/uiconfig/ui/charmapcontrol.ui                         |  201 +++++++++
 9 files changed, 792 insertions(+), 32 deletions(-)

New commits:
commit f9efee1f87262b0088c249b2c306fb53ca729b53
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date:   Mon Jul 10 16:27:57 2017 +0530

    Favourites feature in Special characters
    
    Change-Id: I8273b95132d48a51e841ec3792139007b4e7b55a
    Reviewed-on: https://gerrit.libreoffice.org/39752
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index ad088cfa30e1..6031af5d85fb 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -68,8 +68,8 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, const SfxItemSet* pSet )
     //lock the size request of this widget to the width of all possible entries
     fillAllSubsets(*m_pSubsetLB);
     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");
     //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());
 
@@ -90,6 +90,23 @@ SvxCharacterMap::SvxCharacterMap( vcl::Window* pParent, const SfxItemSet* pSet )
     get( m_pRecentCharView[14], "viewchar15" );
     get( m_pRecentCharView[15], "viewchar16" );
 
+    get( m_pFavCharView[0], "favchar1" );
+    get( m_pFavCharView[1], "favchar2" );
+    get( m_pFavCharView[2], "favchar3" );
+    get( m_pFavCharView[3], "favchar4" );
+    get( m_pFavCharView[4], "favchar5" );
+    get( m_pFavCharView[5], "favchar6" );
+    get( m_pFavCharView[6], "favchar7" );
+    get( m_pFavCharView[7], "favchar8" );
+    get( m_pFavCharView[8], "favchar9" );
+    get( m_pFavCharView[9], "favchar10" );
+    get( m_pFavCharView[10], "favchar11" );
+    get( m_pFavCharView[11], "favchar12" );
+    get( m_pFavCharView[12], "favchar13" );
+    get( m_pFavCharView[13], "favchar14" );
+    get( m_pFavCharView[14], "favchar15" );
+    get( m_pFavCharView[15], "favchar16" );
+
     init();
 
     const SfxInt32Item* pCharItem = SfxItemSet::GetItem<SfxInt32Item>(pSet, SID_ATTR_CHAR, false);
@@ -129,6 +146,7 @@ short SvxCharacterMap::Execute()
     if( SvxShowCharSet::getSelectedChar() == ' ')
     {
         m_pOKBtn->Disable();
+        setFavButtonState(OUString(), OUString());
     }
     else
     {
@@ -136,6 +154,8 @@ short SvxCharacterMap::Execute()
         // using the new UCS4 constructor
         OUString aOUStr( &cChar, 1 );
         m_pShowChar->SetText(aOUStr);
+
+        setFavButtonState(aOUStr, m_pShowChar->GetFont().GetFamilyName());
         m_pOKBtn->Enable();
     }
 
@@ -159,6 +179,10 @@ void SvxCharacterMap::dispose()
 
     maRecentCharList.clear();
     maRecentCharFontList.clear();
+    maFavCharList.clear();
+    maFavCharFontList.clear();
+
+    m_pFavouritesBtn.clear();
 
     SfxModalDialog::dispose();
 }
@@ -167,6 +191,8 @@ void SvxCharacterMap::dispose()
 void SvxCharacterMap::SetChar( sal_UCS4 c )
 {
     m_pShowSet->SelectCharacter( c );
+
+        setFavButtonState(OUString(&c, 1), aFont.GetFamilyName());
 }
 
 
@@ -200,6 +226,25 @@ void SvxCharacterMap::getRecentCharacterList()
     }
 }
 
+
+void SvxCharacterMap::getFavCharacterList()
+{
+    //retrieve recent character list
+    css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
+    for (int i = 0; i < rFavCharList.getLength(); ++i)
+    {
+        maFavCharList.push_back(rFavCharList[i]);
+    }
+
+    //retrieve recent character font list
+    css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() );
+    for (int i = 0; i < rFavCharFontList.getLength(); ++i)
+    {
+        maFavCharFontList.push_back(rFavCharFontList[i]);
+    }
+}
+
+
 void SvxCharacterMap::updateRecentCharControl()
 {
     int i = 0;
@@ -265,6 +310,103 @@ void SvxCharacterMap::updateRecentCharacterList(const OUString& sTitle, const OU
 }
 
 
+void SvxCharacterMap::updateFavCharacterList(const OUString& sTitle, const OUString& rFont)
+{
+    auto itChar = std::find_if(maFavCharList.begin(),
+         maFavCharList.end(),
+         [sTitle] (const OUString & a) { return a == sTitle; });
+
+    auto itChar2 = std::find_if(maFavCharFontList.begin(),
+         maFavCharFontList.end(),
+         [rFont] (const OUString & a) { return a == rFont; });
+
+    // if Fav char to be added is already in list, remove it
+    if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
+    {
+        maFavCharList.erase( itChar );
+        maFavCharFontList.erase( itChar2);
+    }
+
+    if (maFavCharList.size() == 16)
+    {
+        maFavCharList.pop_back();
+        maFavCharFontList.pop_back();
+    }
+
+    maFavCharList.push_back(sTitle);
+    maFavCharFontList.push_back(rFont);
+
+    css::uno::Sequence< OUString > aFavCharList(maFavCharList.size());
+    css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size());
+
+    for (size_t i = 0; i < maFavCharList.size(); ++i)
+    {
+        aFavCharList[i] = maFavCharList[i];
+        aFavCharFontList[i] = maFavCharFontList[i];
+    }
+
+    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();
+}
+
+
+void SvxCharacterMap::updateFavCharControl()
+{
+    int i = 0;
+    for ( std::deque< OUString >::iterator it = maFavCharList.begin(), it2 = maFavCharFontList.begin();
+        it != maFavCharList.end() || it2 != maFavCharFontList.end();
+        ++it, ++it2, i++)
+    {
+        m_pFavCharView[i]->SetText(*it);
+        vcl::Font rFont = m_pFavCharView[i]->GetControlFont();
+        rFont.SetFamilyName( *it2 );
+        m_pFavCharView[i]->SetFont(rFont);
+        m_pFavCharView[i]->Show();
+    }
+
+    for(; i < 16 ; i++)
+    {
+        m_pFavCharView[i]->SetText(OUString());
+        m_pFavCharView[i]->Hide();
+    }
+}
+
+
+void SvxCharacterMap::deleteFavCharacterFromList(const OUString& sTitle, const OUString& rFont)
+{
+    auto itChar = std::find_if(maFavCharList.begin(),
+         maFavCharList.end(),
+         [sTitle] (const OUString & a) { return a == sTitle; });
+
+    auto itChar2 = std::find_if(maFavCharFontList.begin(),
+         maFavCharFontList.end(),
+         [rFont] (const OUString & a) { return a == rFont; });
+
+    // if Fav char to be added is already in list, remove it
+    if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
+    {
+        maFavCharList.erase( itChar );
+        maFavCharFontList.erase( itChar2);
+    }
+
+    css::uno::Sequence< OUString > aFavCharList(maFavCharList.size());
+    css::uno::Sequence< OUString > aFavCharFontList(maFavCharFontList.size());
+
+    for (size_t i = 0; i < maFavCharList.size(); ++i)
+    {
+        aFavCharList[i] = maFavCharList[i];
+        aFavCharFontList[i] = maFavCharFontList[i];
+    }
+
+    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();
+}
+
+
 void SvxCharacterMap::init()
 {
     aFont = GetFont();
@@ -321,6 +463,7 @@ void SvxCharacterMap::init()
     m_pShowSet->SetPreSelectHdl( LINK( this, SvxCharacterMap, CharPreSelectHdl ) );
     m_pDecimalCodeText->SetModifyHdl( LINK( this, SvxCharacterMap, DecimalCodeChangeHdl ) );
     m_pHexCodeText->SetModifyHdl( LINK( this, SvxCharacterMap, HexCodeChangeHdl ) );
+    m_pFavouritesBtn->SetClickHdl( LINK(this, SvxCharacterMap, FavSelectHdl));
 
     if( SvxShowCharSet::getSelectedChar() == ' ')
     {
@@ -332,16 +475,66 @@ void SvxCharacterMap::init()
         // using the new UCS4 constructor
         OUString aOUStr( &cChar, 1 );
         m_pShowChar->SetText(aOUStr);
+
+        setFavButtonState(aOUStr, aDefStr);
         m_pOKBtn->Enable();
     }
 
     getRecentCharacterList();
     updateRecentCharControl();
 
+    getFavCharacterList();
+    updateFavCharControl();
+
     for(int i = 0; i < 16; i++)
     {
-        m_pRecentCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, RecentClickHdl));
+        m_pRecentCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
         m_pRecentCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl));
+        m_pFavCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl));
+        m_pFavCharView[i]->SetLoseFocusHdl(LINK(this,SvxCharacterMap, LoseFocusHdl));
+    }
+}
+
+bool SvxCharacterMap::isFavChar(const OUString& sTitle, const OUString& rFont)
+{
+    auto itChar = std::find_if(maFavCharList.begin(),
+         maFavCharList.end(),
+         [sTitle] (const OUString & a) { return a == sTitle; });
+
+    auto itChar2 = std::find_if(maFavCharFontList.begin(),
+         maFavCharFontList.end(),
+         [rFont] (const OUString & a) { return a == rFont; });
+
+    // if Fav char to be added is already in list, remove it
+    if( itChar != maFavCharList.end() &&  itChar2 != maFavCharFontList.end() )
+        return true;
+    else
+        return false;
+}
+
+
+void SvxCharacterMap::setFavButtonState(const OUString& sTitle, const OUString& rFont)
+{
+    if(sTitle.isEmpty() || rFont.isEmpty())
+    {
+        m_pFavouritesBtn->Disable();
+        return;
+    }
+    else
+        m_pFavouritesBtn->Enable();
+
+    if(isFavChar(sTitle, rFont))
+    {
+        m_pFavouritesBtn->SetText(CuiResId(RID_SVXSTR_REMOVE_FAVORITES));
+    }
+    else
+    {
+        if(maFavCharList.size() == 16)
+        {
+            m_pFavouritesBtn->Disable();
+        }
+
+        m_pFavouritesBtn->SetText(CuiResId(RID_SVXSTR_ADD_FAVORITES));
     }
 }
 
@@ -462,15 +655,19 @@ IMPL_LINK_NOARG(SvxCharacterMap, SubsetSelectHdl, ListBox&, void)
     {
         sal_UCS4 cFirst = pSubset->GetRangeMin();
         m_pShowSet->SelectCharacter( cFirst );
+
+        setFavButtonState(OUString(&cFirst, 1), aFont.GetFamilyName());
     }
     m_pSubsetLB->SelectEntryPos( nPos );
 }
 
-IMPL_LINK(SvxCharacterMap, RecentClickHdl, SvxCharView*, rView, void)
+IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void)
 {
     m_pShowChar->SetText( rView->GetText() );
     m_pShowChar->SetFont(rView->GetFont());
     m_pShowChar->Update();
+
+    setFavButtonState(rView->GetText(), rView->GetFont().GetFamilyName());//check state
     rView->GrabFocus();
 
     // Get the hexadecimal code
@@ -498,6 +695,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharDoubleClickHdl, SvxShowCharSet*, void)
     sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
     // using the new UCS4 constructor
     OUString aOUStr( &cChar, 1 );
+    setFavButtonState(aOUStr, aFont.GetFamilyName());
     insertCharToDoc(aOUStr);
 }
 
@@ -518,6 +716,19 @@ IMPL_STATIC_LINK(SvxCharacterMap, LoseFocusHdl, Control&, pItem, void)
     pItem.Invalidate();
 }
 
+IMPL_LINK_NOARG(SvxCharacterMap, FavSelectHdl, Button*, void)
+{
+    if(m_pFavouritesBtn->GetText().match(CuiResId(RID_SVXSTR_ADD_FAVORITES)))
+        updateFavCharacterList(m_pShowChar->GetText(), m_pShowChar->GetFont().GetFamilyName());
+    else
+    {
+        deleteFavCharacterFromList(m_pShowChar->GetText(), m_pShowChar->GetFont().GetFamilyName());
+        m_pFavouritesBtn->SetText(CuiResId(RID_SVXSTR_ADD_FAVORITES));
+        m_pFavouritesBtn->Disable();
+    }
+
+    updateFavCharControl();
+}
 
 IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
 {
@@ -547,6 +758,8 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
         m_pShowChar->SetText( aText );
         m_pShowChar->SetFont( aFont );
         m_pShowChar->Update();
+
+        setFavButtonState(aText, aFont.GetFamilyName());
     }
 
     // show char codes
@@ -607,6 +820,8 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharPreSelectHdl, SvxShowCharSet*, void)
     if( pSubsetMap )
     {
         sal_UCS4 cChar = m_pShowSet->GetSelectCharacter();
+
+        setFavButtonState(OUString(&cChar, 1), aFont.GetFamilyName());
         const Subset* pSubset = pSubsetMap->GetSubsetByUnicode( cChar );
         if( pSubset )
             m_pSubsetLB->SelectEntry( pSubset->GetName() );
diff --git a/cui/source/dialogs/cuires.src b/cui/source/dialogs/cuires.src
index 5e43e24a21e6..6c22063dee6b 100644
--- a/cui/source/dialogs/cuires.src
+++ b/cui/source/dialogs/cuires.src
@@ -49,6 +49,16 @@ String RID_SVXSTR_ROW
     Text [ en-US ] = "Insert Rows" ;
 };
 
+String RID_SVXSTR_REMOVE_FAVORITES
+{
+    Text [ en-US ] = "Remove from Favorites" ;
+};
+
+String RID_SVXSTR_ADD_FAVORITES
+{
+    Text [ en-US ] = "Add to Favorites" ;
+};
+
 String RID_SVXSTR_PPI
 {
     Text [ x-comment ] = "PPI is pixel per inch, %1 is a number" ;
diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx
index 9d4f5604fb17..ecf3d2cb709f 100644
--- a/cui/source/inc/cuicharmap.hxx
+++ b/cui/source/inc/cuicharmap.hxx
@@ -78,13 +78,19 @@ private:
     VclPtr<SvxShowText>    m_pShowChar;
     VclPtr<Edit>           m_pHexCodeText;
     VclPtr<Edit>           m_pDecimalCodeText;
+    VclPtr<Button>         m_pFavouritesBtn;
     VclPtr<SvxCharView>    m_pRecentCharView[16];
+    VclPtr<SvxCharView>    m_pFavCharView[16];
+
     vcl::Font       aFont;
     const SubsetMap* pSubsetMap;
 
     std::deque<OUString> maRecentCharList;
     std::deque<OUString> maRecentCharFontList;
 
+    std::deque<OUString> maFavCharList;
+    std::deque<OUString> maFavCharFontList;
+
     uno::Reference< uno::XComponentContext > mxContext;
 
     enum class Radix : sal_Int16 {decimal = 10, hexadecimal=16};
@@ -97,9 +103,10 @@ private:
     DECL_LINK(CharPreSelectHdl, SvxShowCharSet*, void);
     DECL_LINK(DecimalCodeChangeHdl, Edit&, void);
     DECL_LINK(HexCodeChangeHdl, Edit&, void);
-    DECL_LINK(RecentClickHdl, SvxCharView*, void);
+    DECL_LINK(CharClickHdl, SvxCharView*, void);
     DECL_LINK(InsertClickHdl, Button*, void);
     DECL_STATIC_LINK(SvxCharacterMap, LoseFocusHdl, Control&, void);
+    DECL_LINK(FavSelectHdl, Button*, void);
 
     static void fillAllSubsets(ListBox &rListBox);
     void selectCharByCode(Radix radix);
@@ -121,8 +128,16 @@ public:
     void            getRecentCharacterList(); //gets both recent char and recent char font list
     void            updateRecentCharacterList(const OUString& rChar, const OUString& rFont);
 
+    void            getFavCharacterList(); //gets both Fav char and Fav char font list
+    void            updateFavCharacterList(const OUString& rChar, const OUString& rFont);
+    void            deleteFavCharacterFromList(const OUString& rChar, const OUString& rFont);
+    bool            isFavChar(const OUString& sTitle, const OUString& rFont);
+
     void            updateRecentCharControl();
     void            insertCharToDoc(const OUString& sChar);
+
+    void            updateFavCharControl();
+    void            setFavButtonState(const OUString& sTitle, const OUString& rFont);
 };
 
 #endif
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index 599063cbca62..16cb33c8d6f2 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -63,6 +63,8 @@
 #define RID_SVXSTR_DESC_NEW_BITMAP          (RID_SVX_START + 168)
 #define RID_SVXSTR_DESC_EXT_BITMAP          (RID_SVX_START + 169)
 #define RID_SVXSTR_DESC_NEW_PATTERN         (RID_SVX_START + 170)
+#define RID_SVXSTR_REMOVE_FAVORITES         (RID_SVX_START + 171)
+#define RID_SVXSTR_ADD_FAVORITES            (RID_SVX_START + 172)
 #define RID_SVXSTR_DESC_LINESTYLE           (RID_SVX_START + 174)
 
 #define RID_SVXSTR_ASK_CHANGE_LINESTYLE     (RID_SVX_START + 177)
diff --git a/cui/uiconfig/ui/specialcharacters.ui b/cui/uiconfig/ui/specialcharacters.ui
index 130f564d24b3..e6429826a57b 100644
--- a/cui/uiconfig/ui/specialcharacters.ui
+++ b/cui/uiconfig/ui/specialcharacters.ui
@@ -2,7 +2,8 @@
 <!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <requires lib="" version="3.0"/>
+  <!-- interface-local-resource-path /home/akki/libreoffice/extras/source/glade -->
   <object class="GtkDialog" id="SpecialCharactersDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -177,12 +178,14 @@
                   <object class="GtkGrid" id="grid4">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="halign">center</property>
                     <property name="row_spacing">3</property>
+                    <property name="column_spacing">6</property>
+                    <property name="row_homogeneous">True</property>
                     <child>
                       <object class="GtkLabel" id="hexlabel">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="halign">start</property>
                         <property name="xalign">0</property>
                         <property name="label" translatable="yes">Hexadecimal:</property>
                       </object>
@@ -192,23 +195,9 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkGrid" id="grid5">
+                      <object class="GtkBox" id="box4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="column_spacing">3</property>
-                        <child>
-                          <object class="GtkEntry" id="hexvalue">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="halign">center</property>
-                            <property name="width_chars">8</property>
-                            <property name="text">A2</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">0</property>
-                          </packing>
-                        </child>
                         <child>
                           <object class="GtkLabel" id="hexulabel">
                             <property name="visible">True</property>
@@ -220,14 +209,28 @@
                             <property name="lines">1</property>
                           </object>
                           <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">0</property>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkEntry" id="hexvalue">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="width_chars">8</property>
+                            <property name="text">A2</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                     <child>
@@ -239,7 +242,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">1</property>
                       </packing>
                     </child>
                     <child>
@@ -250,8 +253,23 @@
                         <property name="text">162</property>
                       </object>
                       <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="favbtn">
+                        <property name="label" translatable="yes">Add to Favorites</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="tooltip_text" translatable="yes">Maximum Limit: 16 Characters</property>
+                        <property name="halign">center</property>
+                      </object>
+                      <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">3</property>
+                        <property name="top_attach">2</property>
+                        <property name="width">2</property>
                       </packing>
                     </child>
                   </object>
@@ -496,6 +514,221 @@
                 <property name="width">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkBox" id="box2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_top">4</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkLabel" id="symboltext2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="valign">start</property>
+                    <property name="label" translatable="yes">Favorite Characters:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkGrid" id="grid6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar1">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar2">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar4">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">3</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar3">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar5">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">4</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar6">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">5</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar7">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">6</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar8">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">7</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar16">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">15</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar15">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">14</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar14">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">13</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar13">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">12</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar12">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">11</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar11">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">10</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar10">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">9</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="cuilo-SvxCharView" id="favchar9">
+                        <property name="width_request">40</property>
+                        <property name="height_request">35</property>
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">8</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>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">3</property>
+                <property name="width">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/include/sfx2/charmapcontrol.hxx b/include/sfx2/charmapcontrol.hxx
index 643978dc13eb..4855c972bba6 100644
--- a/include/sfx2/charmapcontrol.hxx
+++ b/include/sfx2/charmapcontrol.hxx
@@ -40,14 +40,20 @@ public:
 
 private:
     VclPtr<SvxCharView>    m_pRecentCharView[16];
+    VclPtr<SvxCharView>    m_pFavCharView[16];
     std::deque<OUString>   maRecentCharList;
     std::deque<OUString>   maRecentCharFontList;
+    std::deque<OUString>   maFavCharList;
+    std::deque<OUString>   maFavCharFontList;
     VclPtr<Button>         maDlgBtn;
 
-    DECL_LINK(RecentClickHdl, SvxCharView*, void);
+    DECL_LINK(CharClickHdl, SvxCharView*, void);
     DECL_STATIC_LINK(SfxCharmapCtrl, LoseFocusHdl, Control&, void);
     DECL_LINK(OpenDlgHdl, Button*, void);
 
+    void            getFavCharacterList();
+    void            updateFavCharControl();
+
     void            getRecentCharacterList(); //gets both recent char and recent char font list
     void            updateRecentCharacterList(const OUString& rChar, const OUString& rFont);
     void            updateRecentCharControl();
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 5e146982cfaf..bbf4f4eea7d1 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -3493,6 +3493,23 @@
         <value/>
       </prop>
     </group>
+    <group oor:name="FavoriteCharacters">
+      <info>
+        <desc>Contains Favorite characters</desc>
+      </info>
+      <prop oor:name="FavoriteCharacterList" oor:type="oor:string-list" oor:nillable="false">
+        <info>
+          <desc>List of Favorite characters</desc>
+        </info>
+        <value/>
+      </prop>
+      <prop oor:name="FavoriteCharacterFontList" oor:type="oor:string-list" oor:nillable="false">
+        <info>
+          <desc>List of Favorite character font</desc>
+        </info>
+        <value/>
+      </prop>
+    </group>
     <group oor:name="Help">
       <info>
         <desc>Contains settings that specify the common help settings.</desc>
diff --git a/sfx2/source/control/charmapcontrol.cxx b/sfx2/source/control/charmapcontrol.cxx
index 8a2af88d63c0..d8535065621b 100644
--- a/sfx2/source/control/charmapcontrol.cxx
+++ b/sfx2/source/control/charmapcontrol.cxx
@@ -43,18 +43,40 @@ SfxCharmapCtrl::SfxCharmapCtrl(sal_uInt16 nId, const css::uno::Reference< css::f
     get( m_pRecentCharView[13], "viewchar14" );
     get( m_pRecentCharView[14], "viewchar15" );
     get( m_pRecentCharView[15], "viewchar16" );
+
+    get( m_pFavCharView[0], "favchar1" );
+    get( m_pFavCharView[1], "favchar2" );
+    get( m_pFavCharView[2], "favchar3" );
+    get( m_pFavCharView[3], "favchar4" );
+    get( m_pFavCharView[4], "favchar5" );
+    get( m_pFavCharView[5], "favchar6" );
+    get( m_pFavCharView[6], "favchar7" );
+    get( m_pFavCharView[7], "favchar8" );
+    get( m_pFavCharView[8], "favchar9" );
+    get( m_pFavCharView[9], "favchar10" );
+    get( m_pFavCharView[10], "favchar11" );
+    get( m_pFavCharView[11], "favchar12" );
+    get( m_pFavCharView[12], "favchar13" );
+    get( m_pFavCharView[13], "favchar14" );
+    get( m_pFavCharView[14], "favchar15" );
+    get( m_pFavCharView[15], "favchar16" );
+
     get( maDlgBtn, "specialchardlg");
 
     for(int i = 0; i < 16; i++)
     {
-        m_pRecentCharView[i]->setMouseClickHdl(LINK(this,SfxCharmapCtrl, RecentClickHdl));
+        m_pRecentCharView[i]->setMouseClickHdl(LINK(this,SfxCharmapCtrl, CharClickHdl));
         m_pRecentCharView[i]->SetLoseFocusHdl(LINK(this,SfxCharmapCtrl, LoseFocusHdl));
+        m_pFavCharView[i]->setMouseClickHdl(LINK(this,SfxCharmapCtrl, CharClickHdl));
+        m_pFavCharView[i]->SetLoseFocusHdl(LINK(this,SfxCharmapCtrl, LoseFocusHdl));
     }
 
     maDlgBtn->SetClickHdl(LINK(this, SfxCharmapCtrl, OpenDlgHdl));
 
     getRecentCharacterList();
     updateRecentCharControl();
+    getFavCharacterList();
+    updateFavCharControl();
 }
 
 SfxCharmapCtrl::~SfxCharmapCtrl()
@@ -76,6 +98,46 @@ void SfxCharmapCtrl::dispose()
 }
 
 
+void SfxCharmapCtrl::getFavCharacterList()
+{
+    //retrieve recent character list
+    css::uno::Sequence< OUString > rFavCharList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterList::get() );
+    for (int i = 0; i < rFavCharList.getLength(); ++i)
+    {
+        maFavCharList.push_back(rFavCharList[i]);
+    }
+
+    //retrieve recent character font list
+    css::uno::Sequence< OUString > rFavCharFontList( officecfg::Office::Common::FavoriteCharacters::FavoriteCharacterFontList::get() );
+    for (int i = 0; i < rFavCharFontList.getLength(); ++i)
+    {
+        maFavCharFontList.push_back(rFavCharFontList[i]);
+    }
+}
+
+
+void SfxCharmapCtrl::updateFavCharControl()
+{
+    int i = 0;
+    for ( std::deque< OUString >::iterator it = maFavCharList.begin(), it2 = maFavCharFontList.begin();
+        it != maFavCharList.end() || it2 != maFavCharFontList.end();
+        ++it, ++it2, i++)
+    {
+        m_pFavCharView[i]->SetText(*it);
+        vcl::Font rFont = m_pFavCharView[i]->GetControlFont();
+        rFont.SetFamilyName( *it2 );
+        m_pFavCharView[i]->SetFont(rFont);
+        m_pFavCharView[i]->Show();
+    }
+
+    for(; i < 16 ; i++)
+    {
+        m_pFavCharView[i]->SetText(OUString());
+        m_pFavCharView[i]->Hide();
+    }
+}
+
+
 void SfxCharmapCtrl::getRecentCharacterList()
 {
     //retrieve recent character list
@@ -93,6 +155,7 @@ void SfxCharmapCtrl::getRecentCharacterList()
     }
 }
 
+
 void SfxCharmapCtrl::updateRecentCharControl()
 {
     int i = 0;
@@ -164,7 +227,7 @@ IMPL_STATIC_LINK(SfxCharmapCtrl, LoseFocusHdl, Control&, pItem, void)
 }
 
 
-IMPL_LINK(SfxCharmapCtrl, RecentClickHdl, SvxCharView*, rView, void)
+IMPL_LINK(SfxCharmapCtrl, CharClickHdl, SvxCharView*, rView, void)
 {
     rView->GrabFocus();
     rView->Invalidate();
diff --git a/sfx2/uiconfig/ui/charmapcontrol.ui b/sfx2/uiconfig/ui/charmapcontrol.ui
index cc96bdc63837..defc9220c92b 100644
--- a/sfx2/uiconfig/ui/charmapcontrol.ui
+++ b/sfx2/uiconfig/ui/charmapcontrol.ui
@@ -218,6 +218,205 @@
           </packing>
         </child>
         <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Favourites</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="grid2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar1">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar2">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar4">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar3">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar12">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar11">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar10">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar9">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar5">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">4</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar6">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar7">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">6</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar8">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">7</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar13">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">4</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar14">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar15">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">6</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="cuilo-SvxCharView" id="favchar16">
+                <property name="width_request">35</property>
+                <property name="height_request">35</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">7</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkButton" id="specialchardlg">
             <property name="label" translatable="yes">Launch Dialog</property>
             <property name="visible">True</property>
@@ -227,7 +426,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">4</property>
           </packing>
         </child>
       </object>


More information about the Libreoffice-commits mailing list