xref: /aoo41x/main/cui/source/inc/SpellDialog.hxx (revision 8e631f35)
1c4eee24dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c4eee24dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c4eee24dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c4eee24dSAndrew Rist  * distributed with this work for additional information
6c4eee24dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c4eee24dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c4eee24dSAndrew Rist  * "License"); you may not use this file except in compliance
9c4eee24dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c4eee24dSAndrew Rist  *
11c4eee24dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c4eee24dSAndrew Rist  *
13c4eee24dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c4eee24dSAndrew Rist  * software distributed under the License is distributed on an
15c4eee24dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c4eee24dSAndrew Rist  * KIND, either express or implied.  See the License for the
17c4eee24dSAndrew Rist  * specific language governing permissions and limitations
18c4eee24dSAndrew Rist  * under the License.
19c4eee24dSAndrew Rist  *
20c4eee24dSAndrew Rist  *************************************************************/
21c4eee24dSAndrew Rist 
22c4eee24dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SVX_SPELLDDIALOG_HXX
24cdf0e10cSrcweir #define _SVX_SPELLDDIALOG_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // include ---------------------------------------------------------------
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <sfx2/basedlgs.hxx>
29cdf0e10cSrcweir #include <vcl/fixed.hxx>
30cdf0e10cSrcweir #include <vcl/edit.hxx>
31cdf0e10cSrcweir #include <vcl/lstbox.hxx>
32cdf0e10cSrcweir #include <svtools/stdctrl.hxx>
33cdf0e10cSrcweir #include <vcl/button.hxx>
34cdf0e10cSrcweir #include <vcl/menubtn.hxx>
35cdf0e10cSrcweir #include <vcl/group.hxx>
36cdf0e10cSrcweir #include <vcl/decoview.hxx>
37cdf0e10cSrcweir #include <vcl/image.hxx>
38cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <svtools/svxbox.hxx>
42cdf0e10cSrcweir #include <svx/langbox.hxx>
43cdf0e10cSrcweir #include <memory>
44cdf0e10cSrcweir #include <svtools/svmedit.hxx>
45cdf0e10cSrcweir #include <svl/lstner.hxx>
46cdf0e10cSrcweir #include <svtools/xtextedt.hxx>
47cdf0e10cSrcweir #include <editeng/SpellPortions.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <set>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class ScrollBar;
52cdf0e10cSrcweir class TextEngine;
53cdf0e10cSrcweir class ExtTextView;
54cdf0e10cSrcweir namespace svx{ class SpellUndoAction_Impl;}
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // forward ---------------------------------------------------------------
57cdf0e10cSrcweir 
58cdf0e10cSrcweir struct SpellDialog_Impl;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace com{namespace sun{namespace star{
61cdf0e10cSrcweir namespace linguistic2{
62cdf0e10cSrcweir     class XSpellChecker1;
63cdf0e10cSrcweir }}}}
64cdf0e10cSrcweir namespace svx{
65cdf0e10cSrcweir class SpellDialog;
66cdf0e10cSrcweir struct SpellErrorDescription;
67cdf0e10cSrcweir // ------------------------------------------------------------------
68cdf0e10cSrcweir class SentenceEditWindow_Impl : public MultiLineEdit/*, public SfxListener*/
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	using MultiLineEdit::SetText;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir private:
73cdf0e10cSrcweir     std::set< sal_uInt16 >      m_aIgnoreErrorsAt;
74cdf0e10cSrcweir     sal_uInt16          m_nErrorStart;
75cdf0e10cSrcweir     sal_uInt16          m_nErrorEnd;
76cdf0e10cSrcweir     bool            m_bIsUndoEditMode;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     Link            m_aModifyLink;
79cdf0e10cSrcweir 
CallModifyLink()80cdf0e10cSrcweir     void            CallModifyLink() {m_aModifyLink.Call(this);}
81cdf0e10cSrcweir 
GetSpellDialog() const82cdf0e10cSrcweir     SpellDialog*    GetSpellDialog() const {return (SpellDialog*)GetParent();}
83cdf0e10cSrcweir protected:
84cdf0e10cSrcweir     virtual long    PreNotify( NotifyEvent& rNEvt );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir public:
87cdf0e10cSrcweir                     SentenceEditWindow_Impl( SpellDialog* pParent, const ResId& rResId );
88cdf0e10cSrcweir                     ~SentenceEditWindow_Impl();
89cdf0e10cSrcweir 
SetModifyHdl(const Link & rLink)90cdf0e10cSrcweir     void            SetModifyHdl(const Link& rLink) { m_aModifyLink = rLink;}
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     void            SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd );
93cdf0e10cSrcweir     void            SetText( const String& rStr );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     bool            MarkNextError( bool bIgnoreCurrentError );
96cdf0e10cSrcweir     void            ChangeMarkedWord(const String& rNewWord, LanguageType eLanguage);
97cdf0e10cSrcweir     void            MoveErrorMarkTo(sal_uInt16 nErrorStart, sal_uInt16 nErrorEnd, bool bGrammar);
98cdf0e10cSrcweir     String          GetErrorText() const;
99cdf0e10cSrcweir     void            RestoreCurrentError();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     void            SetAlternatives(
102cdf0e10cSrcweir                         com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellAlternatives> );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     const SpellErrorDescription* GetAlternatives();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 
ResetModified()107cdf0e10cSrcweir     void            ResetModified()   { GetTextEngine()->SetModified(sal_False); m_bIsUndoEditMode = false;}
IsModified() const108cdf0e10cSrcweir     sal_Bool            IsModified() const              { return GetTextEngine()->IsModified(); }
109cdf0e10cSrcweir 
IsUndoEditMode() const110cdf0e10cSrcweir     bool            IsUndoEditMode() const { return m_bIsUndoEditMode;}
111cdf0e10cSrcweir     void            SetUndoEditMode(bool bSet);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     svx::SpellPortions  CreateSpellPortions( bool bSetIgnoreFlag ) const;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     void            ResetUndo();
116cdf0e10cSrcweir     void            Undo();
117cdf0e10cSrcweir     void            AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg=sal_False );
118cdf0e10cSrcweir     sal_uInt16      GetUndoActionCount();
119cdf0e10cSrcweir     void            UndoActionStart( sal_uInt16 nId );
120cdf0e10cSrcweir     void            UndoActionEnd();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     void            MoveErrorEnd(long nOffset);
123cdf0e10cSrcweir 
ResetIgnoreErrorsAt()124cdf0e10cSrcweir     void            ResetIgnoreErrorsAt()   { m_aIgnoreErrorsAt.clear(); }
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // class SvxSpellDialog ---------------------------------------------
129cdf0e10cSrcweir class SpellDialogChildWindow;
130cdf0e10cSrcweir class ExplainButton : public PushButton
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     String              m_sExplanation;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual void        RequestHelp( const HelpEvent& rHEvt );
135cdf0e10cSrcweir     virtual void        Click();
136cdf0e10cSrcweir public:
ExplainButton(Window * pParent,const ResId & rResId)137cdf0e10cSrcweir     ExplainButton( Window* pParent, const ResId& rResId ) : PushButton( pParent, rResId ){}
138cdf0e10cSrcweir     ~ExplainButton();
SetExplanation(const String & rText)139cdf0e10cSrcweir     void                SetExplanation( const String& rText ) {m_sExplanation = rText;}
HasExplanation()140cdf0e10cSrcweir     bool                HasExplanation() { return m_sExplanation.Len() > 0;}
141cdf0e10cSrcweir 
142cdf0e10cSrcweir };
143cdf0e10cSrcweir 
144cdf0e10cSrcweir class SpellDialog : public SfxModelessDialog
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	using Window::Invalidate;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	friend class SentenceEditWindow_Impl;
149cdf0e10cSrcweir private:
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     FixedImage      aVendorImageFI;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     FixedText       aLanguageFT;
154cdf0e10cSrcweir     SvxLanguageBox  aLanguageLB;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     FixedText           aNotInDictFT;
157cdf0e10cSrcweir     SentenceEditWindow_Impl  aSentenceED;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     FixedText       aSuggestionFT;
160cdf0e10cSrcweir     ListBox         aSuggestionLB;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     PushButton      aIgnorePB;
163cdf0e10cSrcweir     PushButton      aIgnoreAllPB;
164cdf0e10cSrcweir     PushButton      aIgnoreRulePB;
165cdf0e10cSrcweir     MenuButton      aAddToDictMB;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     PushButton      aChangePB;
168cdf0e10cSrcweir     PushButton      aChangeAllPB;
169cdf0e10cSrcweir     ExplainButton   aExplainPB;
170cdf0e10cSrcweir     PushButton      aAutoCorrPB;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     CheckBox        aCheckGrammarCB;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     HelpButton      aHelpPB;
175cdf0e10cSrcweir     PushButton      aOptionsPB;
176cdf0e10cSrcweir     PushButton      aUndoPB;
177cdf0e10cSrcweir     PushButton      aClosePB;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     GroupBox        aBackgroundGB;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     Image           aVendorImage;
182cdf0e10cSrcweir     Image           aVendorImageHC;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     String          aResumeST;
185cdf0e10cSrcweir     String          aIgnoreOnceST;
186cdf0e10cSrcweir     String          aNoSuggestionsST;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     const String    m_sTitleSpelling;
189cdf0e10cSrcweir     const String    m_sTitleSpellingGrammar;
190cdf0e10cSrcweir     const String    m_sTitleSpellingGrammarVendor;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     Size            aOldWordEDSize;
193cdf0e10cSrcweir     Link            aDialogUndoLink;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     bool            bModified;
196cdf0e10cSrcweir     bool            bFocusLocked;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     svx::SpellDialogChildWindow& rParent;
199cdf0e10cSrcweir     svx::SpellPortions           m_aSavedSentence;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     SpellDialog_Impl* pImpl;
202cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
203cdf0e10cSrcweir 		::com::sun::star::linguistic2::XSpellChecker1 > 	xSpell;
204cdf0e10cSrcweir 	LanguageType		nOldLang;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     DECL_LINK( ChangeHdl, Button * );
207cdf0e10cSrcweir     DECL_LINK( ChangeAllHdl, Button * );
208cdf0e10cSrcweir     DECL_LINK( IgnoreAllHdl, Button * );
209cdf0e10cSrcweir     DECL_LINK( IgnoreHdl, Button * );
210cdf0e10cSrcweir     DECL_LINK( CheckGrammarHdl, CheckBox* );
211cdf0e10cSrcweir 	DECL_LINK( ExtClickHdl, Button * );
212cdf0e10cSrcweir 	DECL_LINK( CancelHdl, Button * );
213cdf0e10cSrcweir     DECL_LINK( ModifyHdl, SentenceEditWindow_Impl *);
214cdf0e10cSrcweir     DECL_LINK( UndoHdl, Button * );
215*8e631f35SAriel Constenla-Haile     DECL_LINK( MenuButtonActivateHdl, MenuButton* );
216cdf0e10cSrcweir     DECL_LINK( AddToDictionaryHdl, MenuButton* );
217cdf0e10cSrcweir     DECL_LINK( LanguageSelectHdl, SvxLanguageBox* );
218cdf0e10cSrcweir     DECL_LINK( DialogUndoHdl, SpellUndoAction_Impl* );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     DECL_STATIC_LINK( SpellDialog, InitHdl, SpellDialog * );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	void            StartSpellOptDlg_Impl();
223cdf0e10cSrcweir 	void            InitUserDicts();
224cdf0e10cSrcweir 	void            UpdateBoxes_Impl();
225cdf0e10cSrcweir 	void            Init_Impl();
226cdf0e10cSrcweir     void            SpellContinue_Impl(bool UseSavedSentence = false, bool bIgnoreCurrentError = false );
LockFocusChanges(bool bLock)227cdf0e10cSrcweir     void            LockFocusChanges( bool bLock ) {bFocusLocked = bLock;}
228cdf0e10cSrcweir     void            Impl_Restore();
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	void			SetSelectedLang_Impl( LanguageType nLang );
231cdf0e10cSrcweir 	LanguageType	GetSelectedLang_Impl() const;
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     /** Retrieves the next sentence.
234cdf0e10cSrcweir      */
235cdf0e10cSrcweir     bool            GetNextSentence_Impl(bool bUseSavedSentence, bool bRechek /*for rechecking the curretn sentence*/);
236cdf0e10cSrcweir     /** Corrects all errors that have been selected to be changed always
237cdf0e10cSrcweir      */
238cdf0e10cSrcweir     bool            ApplyChangeAllList_Impl(SpellPortions& rSentence, bool& bHasReplaced);
239cdf0e10cSrcweir     void            SetTitle_Impl(LanguageType nLang);
240cdf0e10cSrcweir 
241cdf0e10cSrcweir protected:
242cdf0e10cSrcweir     virtual void    Paint( const Rectangle& rRect );
243cdf0e10cSrcweir     virtual long    Notify( NotifyEvent& rNEvt );
244cdf0e10cSrcweir 
245cdf0e10cSrcweir public:
246cdf0e10cSrcweir     SpellDialog(
247cdf0e10cSrcweir         svx::SpellDialogChildWindow* pChildWindow,
248cdf0e10cSrcweir         Window * pParent,
249cdf0e10cSrcweir         SfxBindings* pBindings);
250cdf0e10cSrcweir     ~SpellDialog();
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	void			SetLanguage( sal_uInt16 nLang );
253cdf0e10cSrcweir 	virtual sal_Bool	Close();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     void            InvalidateDialog();
256cdf0e10cSrcweir };
257cdf0e10cSrcweir } //namespace svx
258cdf0e10cSrcweir 
259cdf0e10cSrcweir #endif
260cdf0e10cSrcweir 
261