Blob Blame History Raw
From f46860e84df8548daa12f180f27deef7a1d708d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Fri, 13 Nov 2015 09:56:01 +0000
Subject: [PATCH] Resolves: tdf#95682 spell dialog: add a button to open
 special character

(cherry picked from commit b08b76774fbd253cba587207d471f9bf0c0b0a82)

Change-Id: I0d070dee9e940b93b294c6b2de180005a5c2248e

Related: tdf#95682 set edit to modified after insert symbol/paste

Change-Id: If5892931649bde3d1fc00c0e5817149d0623cb1e
(cherry picked from commit de0a391137080a18e73f315b6dc5342b5b078574)

clear VclPtr warning

Change-Id: I13f08989034a656bc6f0ae6b556272802f4b8fc2
(cherry picked from commit 9c7d3345b02bcf69f28bdbc956a7cedaabe894a0)
---
 cui/source/dialogs/SpellDialog.cxx |  54 ++++++++++++--
 cui/source/inc/SpellDialog.hxx     |   8 +++
 cui/uiconfig/ui/spellingdialog.ui  | 143 ++++++++++++++++++++-----------------
 3 files changed, 135 insertions(+), 70 deletions(-)

diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index f8952df..7f09b7f 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -222,6 +222,8 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow,
     get(m_pOptionsPB, "options");
     get(m_pUndoPB, "undo");
     get(m_pClosePB, "close");
+    get(m_pToolbar, "toolbar");
+    m_pSentenceED->Init(m_pToolbar);
     xSpell = LinguMgr::GetSpellChecker();
     pImpl = new SpellDialog_Impl;
 
@@ -243,8 +245,6 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow,
         LINK( this, SpellDialog, InitHdl ), NULL, true );
 }
 
-
-
 SpellDialog::~SpellDialog()
 {
     disposeOnce();
@@ -282,6 +282,7 @@ void SpellDialog::dispose()
     m_pOptionsPB.clear();
     m_pUndoPB.clear();
     m_pClosePB.clear();
+    m_pToolbar.clear();
     SfxModelessDialog::dispose();
 }
 
@@ -318,8 +319,6 @@ void SpellDialog::Init_Impl()
     SvxGetChangeAllList()->clear();
 }
 
-
-
 void SpellDialog::UpdateBoxes_Impl()
 {
     sal_Int32 i;
@@ -443,6 +442,7 @@ void SpellDialog::SpellContinue_Impl(bool bUseSavedSentence, bool bIgnoreCurrent
  */
 IMPL_LINK( SpellDialog, InitHdl, SpellDialog *, )
 {
+    m_pToolbar->Disable();
     SetUpdateMode( false );
     //show or hide AutoCorrect depending on the modules abilities
     m_pAutoCorrPB->Show(rParent.HasAutoCorrection());
@@ -1219,6 +1219,11 @@ SentenceEditWindow_Impl::SentenceEditWindow_Impl(vcl::Window * pParent, WinBits
     DisableSelectionOnFocus();
 }
 
+SentenceEditWindow_Impl::~SentenceEditWindow_Impl()
+{
+    disposeOnce();
+}
+
 VCL_BUILDER_DECL_FACTORY(SentenceEditWindow)
 {
     (void)rMap;
@@ -1559,9 +1564,50 @@ bool SentenceEditWindow_Impl::PreNotify( NotifyEvent& rNEvt )
         else
             bChange = false;
     }
+    else if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS && m_xToolbar)
+    {
+        m_xToolbar->Enable();
+    }
+    else if(rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS && m_xToolbar)
+    {
+        m_xToolbar->Disable();
+    }
     return bChange || VclMultiLineEdit::PreNotify(rNEvt);
 }
 
+void SentenceEditWindow_Impl::Init(VclPtr<ToolBox> &rToolbar)
+{
+    m_xToolbar = rToolbar;
+    m_xToolbar->SetSelectHdl(LINK(this,SentenceEditWindow_Impl,ToolbarHdl));
+}
+
+IMPL_LINK_NOARG_TYPED(SentenceEditWindow_Impl, ToolbarHdl, ToolBox *, void)
+{
+    const sal_uInt16 nCurItemId = m_xToolbar->GetCurItemId();
+    if (nCurItemId == m_xToolbar->GetItemId("paste"))
+    {
+        Paste();
+        CallModifyLink();
+    }
+    else if (nCurItemId == m_xToolbar->GetItemId("insert"))
+    {
+        if (Edit::GetGetSpecialCharsFunction())
+        {
+            OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() );
+            if (!aChars.isEmpty())
+            {
+                ReplaceSelected(aChars);
+                CallModifyLink();
+            }
+        }
+    }
+}
+
+void SentenceEditWindow_Impl::dispose()
+{
+    m_xToolbar.clear();
+    VclMultiLineEdit::dispose();
+}
 
 bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError, com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xSpell )
 {
diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx
index 38a08cf..543581c 100644
--- a/cui/source/inc/SpellDialog.hxx
+++ b/cui/source/inc/SpellDialog.hxx
@@ -29,6 +29,7 @@
 #include <vcl/group.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/image.hxx>
+#include <vcl/toolbox.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 
 
@@ -62,6 +63,7 @@ class SentenceEditWindow_Impl : public VclMultiLineEdit
 
 private:
     std::set< sal_uInt16 >      m_aIgnoreErrorsAt;
+    VclPtr<ToolBox>     m_xToolbar;
     sal_uInt16          m_nErrorStart;
     sal_uInt16          m_nErrorEnd;
     bool            m_bIsUndoEditMode;
@@ -71,13 +73,17 @@ private:
     void            CallModifyLink() {m_aModifyLink.Call(this);}
 
     inline SpellDialog* GetSpellDialog() const;
+
+    DECL_LINK_TYPED(ToolbarHdl, ToolBox*, void);
 protected:
     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
 
 public:
     SentenceEditWindow_Impl(vcl::Window* pParent, WinBits nBits);
+    ~SentenceEditWindow_Impl();
 
     void            SetModifyHdl(const Link<>& rLink) SAL_OVERRIDE { m_aModifyLink = rLink;}
+    void            Init(VclPtr<ToolBox> &rToolbar);
 
     void            SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd );
     void            SetText( const OUString& rStr ) SAL_OVERRIDE;
@@ -96,6 +102,7 @@ public:
 
     void            ResetModified()   { GetTextEngine()->SetModified(false); m_bIsUndoEditMode = false;}
     virtual bool    IsModified() const SAL_OVERRIDE { return GetTextEngine()->IsModified(); }
+    virtual void    dispose() SAL_OVERRIDE;
 
     bool            IsUndoEditMode() const { return m_bIsUndoEditMode;}
     void            SetUndoEditMode(bool bSet);
@@ -151,6 +158,7 @@ private:
     VclPtr<PushButton>     m_pOptionsPB;
     VclPtr<PushButton>     m_pUndoPB;
     VclPtr<CloseButton>    m_pClosePB;
+    VclPtr<ToolBox>        m_pToolbar;
 
     OUString        m_sResumeST;
     OUString        m_sIgnoreOnceST;
diff --git a/cui/uiconfig/ui/spellingdialog.ui b/cui/uiconfig/ui/spellingdialog.ui
index 5d89284..94b5307 100644
--- a/cui/uiconfig/ui/spellingdialog.ui
+++ b/cui/uiconfig/ui/spellingdialog.ui
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.19.0 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
-  <!-- interface-requires LibreOffice 1.0 -->
+  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkDialog" id="SpellingDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -103,24 +103,6 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="notindictft">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Not in dictionary</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">sentence</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -135,8 +117,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -154,22 +134,6 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="suggestionsft">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Suggestions</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">suggestionslb</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">8</property>
-                <property name="width">3</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkButton" id="change">
                 <property name="label" translatable="yes">Co_rrect</property>
                 <property name="visible">True</property>
@@ -181,8 +145,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">9</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -197,8 +159,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">10</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -213,8 +173,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">11</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -231,7 +189,6 @@
                 <property name="left_attach">0</property>
                 <property name="top_attach">12</property>
                 <property name="width">3</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -246,8 +203,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">4</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -262,39 +217,34 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">5</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkLabel" id="languageft">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes">Text languag_e:</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">languagelb</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkLabel" id="explain">
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
-                <property name="xalign">0</property>
                 <property name="use_underline">True</property>
                 <property name="wrap">True</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">1</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -309,8 +259,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -323,8 +271,6 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">13</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -337,8 +283,6 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="top_attach">13</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -351,8 +295,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">13</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -384,8 +326,6 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">6</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -400,11 +340,82 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="top_attach">7</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="suggestionsft">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Suggestions</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">suggestionslb</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">8</property>
+                <property name="width">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="notindictft">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="label" translatable="yes">_Not in dictionary</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">sentence</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolbar" id="toolbar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">end</property>
+                <property name="toolbar_style">icons</property>
+                <child>
+                  <object class="GtkToolButton" id="paste">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="action_name">paste</property>
+                    <property name="label" translatable="yes">Paste</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">cmd/sc_paste.png</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkToolButton" id="insert">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="action_name">insert</property>
+                    <property name="label" translatable="yes">Special Character</property>
+                    <property name="use_underline">True</property>
+                    <property name="icon_name">cmd/sc_insertsymbol.png</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="homogeneous">True</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
               <placeholder/>
             </child>
           </object>
-- 
2.5.0