1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir import com.sun.star.linguistic2.XLinguServiceEventBroadcaster;
25cdf0e10cSrcweir import com.sun.star.linguistic2.XLinguServiceEventListener;
26cdf0e10cSrcweir import com.sun.star.linguistic2.LinguServiceEvent;
27cdf0e10cSrcweir import com.sun.star.linguistic2.LinguServiceEventFlags;
28cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
29cdf0e10cSrcweir import com.sun.star.beans.XPropertyChangeListener;
30cdf0e10cSrcweir import com.sun.star.beans.PropertyChangeEvent;
31cdf0e10cSrcweir import com.sun.star.lang.EventObject;
32cdf0e10cSrcweir import com.sun.star.uno.XInterface;
33cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir import java.util.ArrayList;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir public class PropChgHelper_Spell extends PropChgHelper
38cdf0e10cSrcweir {
PropChgHelper_Spell( XInterface xEvtSource, String[] aPropNames )39cdf0e10cSrcweir     public PropChgHelper_Spell(
40cdf0e10cSrcweir             XInterface      xEvtSource,
41cdf0e10cSrcweir             String[]        aPropNames )
42cdf0e10cSrcweir     {
43cdf0e10cSrcweir         super( xEvtSource, aPropNames );
44cdf0e10cSrcweir     }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     //************************
47cdf0e10cSrcweir 	// XPropertyChangeListener
48cdf0e10cSrcweir     //************************
propertyChange( PropertyChangeEvent aEvt )49cdf0e10cSrcweir     public void propertyChange( PropertyChangeEvent aEvt )
50cdf0e10cSrcweir             throws com.sun.star.uno.RuntimeException
51cdf0e10cSrcweir     {
52cdf0e10cSrcweir         {
53cdf0e10cSrcweir             short nLngSvcFlags = 0;
54cdf0e10cSrcweir             boolean bSCWA = false;  // SPELL_CORRECT_WORDS_AGAIN ?
55cdf0e10cSrcweir             boolean bSWWA = false;  // SPELL_WRONG_WORDS_AGAIN ?
56cdf0e10cSrcweir 
57cdf0e10cSrcweir             boolean bVal = ((Boolean) aEvt.NewValue).booleanValue();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir             if (aEvt.PropertyName.equals( "IsIgnoreControlCharacters" ))
60cdf0e10cSrcweir             {
61cdf0e10cSrcweir                 // nothing to be done
62cdf0e10cSrcweir             }
63cdf0e10cSrcweir             else if (aEvt.PropertyName.equals( "IsGermanPreReform" ))
64cdf0e10cSrcweir             {
65cdf0e10cSrcweir                 bSCWA = bSWWA = true;
66cdf0e10cSrcweir             }
67cdf0e10cSrcweir             else if (aEvt.PropertyName.equals( "IsUseDictionaryList" ))
68cdf0e10cSrcweir             {
69cdf0e10cSrcweir                 bSCWA = bSWWA = true;
70cdf0e10cSrcweir             }
71cdf0e10cSrcweir             else if (aEvt.PropertyName.equals( "IsSpellUpperCase" ))
72cdf0e10cSrcweir             {
73cdf0e10cSrcweir                 bSCWA = false == bVal;          // FALSE->TRUE change?
74cdf0e10cSrcweir                 bSWWA = !bSCWA;                 // TRUE->FALSE change?
75cdf0e10cSrcweir             }
76cdf0e10cSrcweir             else if (aEvt.PropertyName.equals( "IsSpellWithDigits" ))
77cdf0e10cSrcweir             {
78cdf0e10cSrcweir                 bSCWA = false == bVal;          // FALSE->TRUE change?
79cdf0e10cSrcweir                 bSWWA = !bSCWA;                 // TRUE->FALSE change?
80cdf0e10cSrcweir             }
81cdf0e10cSrcweir             else if (aEvt.PropertyName.equals( "IsSpellCapitalization" ))
82cdf0e10cSrcweir             {
83cdf0e10cSrcweir                 bSCWA = false == bVal;      // FALSE->TRUE change?
84cdf0e10cSrcweir                 bSWWA = !bSCWA;             // TRUE->FALSE change?
85cdf0e10cSrcweir             }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir             if (bSCWA)
88cdf0e10cSrcweir                 nLngSvcFlags |= LinguServiceEventFlags.SPELL_CORRECT_WORDS_AGAIN;
89cdf0e10cSrcweir             if (bSWWA)
90cdf0e10cSrcweir                 nLngSvcFlags |= LinguServiceEventFlags.SPELL_WRONG_WORDS_AGAIN;
91cdf0e10cSrcweir             if (nLngSvcFlags != 0)
92cdf0e10cSrcweir             {
93cdf0e10cSrcweir                 LinguServiceEvent aEvent = new LinguServiceEvent( GetEvtSource(), nLngSvcFlags );
94cdf0e10cSrcweir                 LaunchEvent( aEvent );
95cdf0e10cSrcweir             }
96cdf0e10cSrcweir         }
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100