xref: /AOO41X/main/cui/source/inc/optdict.hxx (revision 277251aa7ecd29029fba9e68f043c890fa833362)
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 #ifndef _SVX_OPTDICT_HXX
23 #define _SVX_OPTDICT_HXX
24 
25 // include ---------------------------------------------------------------
26 
27 #include <vcl/dialog.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/lstbox.hxx>
30 #ifndef _SV_BUTTON_HXX //autogen
31 #include <vcl/button.hxx>
32 #endif
33 #include <vcl/group.hxx>
34 #include <vcl/combobox.hxx>
35 #include <vcl/timer.hxx>
36 #include <vcl/edit.hxx>
37 #include <vcl/decoview.hxx>
38 #include <com/sun/star/util/Language.hpp>
39 #include <com/sun/star/uno/Reference.hxx>
40 #include <com/sun/star/uno/Sequence.hxx>
41 
42 
43 #include <svx/simptabl.hxx>
44 #include <svx/langbox.hxx>
45 
46 namespace com{namespace sun{namespace star{
47 namespace linguistic2{
48     class XDictionary;
49     class XSpellChecker1;
50     class XSpellChecker;
51 }}}}
52 
53 // forward ---------------------------------------------------------------
54 
55 
56 // class SvxNewDictionaryDialog ------------------------------------------
57 
58 class SvxNewDictionaryDialog : public ModalDialog
59 {
60 private:
61     FixedLine           aNewDictBox;
62     FixedText           aNameText;
63     Edit                aNameEdit;
64     FixedText           aLanguageText;
65     SvxLanguageBox      aLanguageLB;
66     CheckBox            aExceptBtn;
67     OKButton            aOKBtn;
68     CancelButton        aCancelBtn;
69     HelpButton          aHelpBtn;
70     ::com::sun::star::uno::Reference<
71         ::com::sun::star::linguistic2::XSpellChecker1 >     xSpell;
72     ::com::sun::star::uno::Reference<
73         ::com::sun::star::linguistic2::XDictionary >    xNewDic;
74 
75 #ifdef _SVX_OPTDICT_CXX
76     DECL_LINK( OKHdl_Impl, Button * );
77     DECL_LINK( ModifyHdl_Impl, Edit * );
78 #endif
79 
80 public:
81     SvxNewDictionaryDialog( Window* pParent,
82             ::com::sun::star::uno::Reference<
83                 ::com::sun::star::linguistic2::XSpellChecker1 >  &xSpl );
84 
85     ::com::sun::star::uno::Reference<
86         ::com::sun::star::linguistic2::XDictionary >
GetNewDictionary()87                 GetNewDictionary() { return xNewDic; }
88 };
89 
90 // class SvxDictEdit ----------------------------------------------------
91 
92 class SvxDictEdit : public Edit
93 {
94     Link    aActionLink;
95     sal_Bool    bSpaces;
96 
97     public:
SvxDictEdit(Window * pParent,const ResId & rResId)98                     SvxDictEdit(Window* pParent, const ResId& rResId) :
99                         Edit(pParent, rResId), bSpaces(sal_False){}
100 
SetActionHdl(const Link & rLink)101     void            SetActionHdl( const Link& rLink )
102                                 { aActionLink = rLink;}
103 
SetSpaces(sal_Bool bSet)104     void            SetSpaces(sal_Bool bSet)
105                                 {bSpaces = bSet;}
106 
107     virtual void    KeyInput( const KeyEvent& rKEvent );
108 };
109 
110 // class SvxEditDictionaryDialog -----------------------------------------
111 
112 class SvxEditDictionaryDialog : public ModalDialog
113 {
114 private:
115 
116     FixedText               aBookFT;
117     ListBox                 aAllDictsLB;
118     FixedText               aLangFT;
119     SvxLanguageBox          aLangLB;
120 
121     FixedText               aWordFT;
122     SvxDictEdit             aWordED;
123     FixedText               aReplaceFT;
124     SvxDictEdit             aReplaceED;
125     SvTabListBox            aWordsLB;
126     PushButton              aNewReplacePB;
127     PushButton              aDeletePB;
128     GroupBox                aEditDictsBox;
129 
130     HelpButton              aHelpBtn;
131     CancelButton            aCloseBtn;
132     String                  sModify;
133     String                  sNew;
134     DecorationView          aDecoView;
135 
136     ::com::sun::star::uno::Sequence<
137         ::com::sun::star::uno::Reference<
138             ::com::sun::star::linguistic2::XDictionary >  > aDics;  //! snapshot copy to work on
139     ::com::sun::star::uno::Reference<
140         ::com::sun::star::linguistic2::XSpellChecker1 >     xSpell;
141 
142     short               nOld;
143     long                nWidth;
144     sal_Bool            bFirstSelect;
145     sal_Bool            bDoNothing;
146     sal_Bool                bDicIsReadonly;
147 
148 #ifdef _SVX_OPTDICT_CXX
149     DECL_LINK( SelectBookHdl_Impl, ListBox * );
150     DECL_LINK( SelectLangHdl_Impl, ListBox * );
151     DECL_LINK(SelectHdl, SvTabListBox*);
152     DECL_LINK(NewDelHdl, PushButton*);
153     DECL_LINK(ModifyHdl, Edit*);
154 
155 
156     void            ShowWords_Impl( sal_uInt16 nId );
157     void            SetLanguage_Impl( ::com::sun::star::util::Language nLanguage );
IsDicReadonly_Impl() const158     sal_Bool            IsDicReadonly_Impl() const { return bDicIsReadonly; }
159     void            SetDicReadonly_Impl( ::com::sun::star::uno::Reference<
160                             ::com::sun::star::linguistic2::XDictionary >  &xDic );
161 
162     void            RemoveDictEntry(SvLBoxEntry* pEntry);
163     sal_uInt16          GetLBInsertPos(const String &rDicWord);
164 
165 #endif
166 
167 protected:
168 
169     virtual void    Paint( const Rectangle& rRect );
170 
171 public:
172     SvxEditDictionaryDialog( Window* pParent,
173             const String& rName,
174             ::com::sun::star::uno::Reference<
175                 ::com::sun::star::linguistic2::XSpellChecker1> &xSpl );
176     ~SvxEditDictionaryDialog();
177 
GetSelectedDict()178     sal_uInt16 GetSelectedDict() {return aAllDictsLB.GetSelectEntryPos();}
179 };
180 
181 #endif
182