1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SVX_SPELL_DIALOG_CHILD_WINDOW_HXX
25 #define SVX_SPELL_DIALOG_CHILD_WINDOW_HXX
26 
27 #include <sfx2/childwin.hxx>
28 #include <editeng/SpellPortions.hxx>
29 #include "svx/svxdllapi.h"
30 #include <vcl/image.hxx>
31 
32 class AbstractSpellDialog;
33 
34 namespace svx {
35 
36 /** The child window wrapper of the actual spellin dialog.  To use the
37     spelling dialog in an application you have to do the ususal things:
38     <ol>
39     <li>Call this class' RegisterChildWindow() method with the module
40     as second argument that you want the dialog included in.</li>
41     <li>In the SFX_IMPL_INTERFACE implementation of the view shell
42     that wants to use the dialog call SFX_CHILDWINDOW_REGISTRATION()
43     with the id returned by this class' GetChildWindowId()
44     method.</li>
45     <li>Include the item associated with this child window to the SDI
46     description of the view shell.</li>
47     </ol>
48 */
49 class SVX_DLLPUBLIC SpellDialogChildWindow
50     : public SfxChildWindow
51 {
52     friend class SpellDialog;
53     AbstractSpellDialog* m_pAbstractSpellDialog;
54 public:
55     SpellDialogChildWindow (
56         Window*pParent,
57         sal_uInt16 nId,
58         SfxBindings* pBindings,
59         SfxChildWinInfo* pInfo);
60     virtual ~SpellDialogChildWindow ();
61 
62 protected:
63     /** This abstract method has to be defined by a derived class.  It
64         returns the next wrong sentence.
65         @return
66             returns an empty vector if no error could be found
67     */
68     virtual SpellPortions GetNextWrongSentence (bool bRecheck) = 0;
69 
70     /** This abstract method applies the changes made in the spelling dialog
71      to the document.
72      The dialog always updates its settings when it gets the focus. The document
73      can rely on the fact that the methods ApplyChangedSentence() is called for the
74      position that the last GetNextWrongSentence() returned.
75      If 'bRecheck' is set to true then the same sentence should be rechecked once from
76      the start. This should be used too find errors that the user has introduced by
77      manual changes in the edit field, and in order to not miss the still following errors
78      in that sentence.
79     */
80     virtual void ApplyChangedSentence(const SpellPortions& rChanged, bool bRecheck ) = 0;
81     /** This methods determines whether the application supports AutoCorrection
82      */
83     virtual bool HasAutoCorrection();
84     /** This method adds a word pair to the AutoCorrection - if available
85      */
86     virtual void AddAutoCorrection(const String& rOld, const String& rNew, LanguageType eLanguage);
87     /** Return the sfx bindings for this child window. They are
88         retrieved from the dialog so they do not have to be stored in
89         this class as well.  The bindings may be necessary to be used
90         by the abstract methods.
91     */
92     /** This method determines if grammar checking is supported
93      */
94     virtual bool HasGrammarChecking();
95     /** determines if grammar checking is switched on
96      */
97     virtual bool IsGrammarChecking();
98     /** switches grammar checking on/off
99      */
100     virtual void SetGrammarChecking(bool bOn);
101 
102     SfxBindings& GetBindings (void) const;
103     /** Set the spell dialog into the 'resume' state. This method should be called
104         to notify the SpellDialog about changes in the document that invalidate the
105         current state which results in disabling most of the dialog controls and presenting
106         a "Resume" button that initiates a reinitialization.
107      */
108     void    InvalidateSpellDialog();
109     /** Notifies the ChildWindow about the get focus event. The ChildWindow should no check if
110         the spelling dialog should be set to the 'Resume' state by calling InvalidateSpellDialog()
111      */
112     virtual void    GetFocus() = 0;
113     /** Notifies the ChildWindow about the lose focus event. The ChildWindow should use it to save
114         the current selection/state.
115      */
116     virtual void    LoseFocus() = 0;
117 };
118 
119 } // end of namespace ::svx
120 
121 #endif
122