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