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 import com.sun.star.linguistic2.XLinguServiceEventBroadcaster; 25 import com.sun.star.linguistic2.XLinguServiceEventListener; 26 import com.sun.star.linguistic2.LinguServiceEvent; 27 import com.sun.star.linguistic2.LinguServiceEventFlags; 28 import com.sun.star.beans.XPropertySet; 29 import com.sun.star.beans.XPropertyChangeListener; 30 import com.sun.star.beans.PropertyChangeEvent; 31 import com.sun.star.lang.EventObject; 32 import com.sun.star.uno.XInterface; 33 import com.sun.star.uno.UnoRuntime; 34 35 import java.util.ArrayList; 36 37 public class PropChgHelper_Spell extends PropChgHelper 38 { PropChgHelper_Spell( XInterface xEvtSource, String[] aPropNames )39 public PropChgHelper_Spell( 40 XInterface xEvtSource, 41 String[] aPropNames ) 42 { 43 super( xEvtSource, aPropNames ); 44 } 45 46 //************************ 47 // XPropertyChangeListener 48 //************************ propertyChange( PropertyChangeEvent aEvt )49 public void propertyChange( PropertyChangeEvent aEvt ) 50 throws com.sun.star.uno.RuntimeException 51 { 52 { 53 short nLngSvcFlags = 0; 54 boolean bSCWA = false; // SPELL_CORRECT_WORDS_AGAIN ? 55 boolean bSWWA = false; // SPELL_WRONG_WORDS_AGAIN ? 56 57 boolean bVal = ((Boolean) aEvt.NewValue).booleanValue(); 58 59 if (aEvt.PropertyName.equals( "IsIgnoreControlCharacters" )) 60 { 61 // nothing to be done 62 } 63 else if (aEvt.PropertyName.equals( "IsGermanPreReform" )) 64 { 65 bSCWA = bSWWA = true; 66 } 67 else if (aEvt.PropertyName.equals( "IsUseDictionaryList" )) 68 { 69 bSCWA = bSWWA = true; 70 } 71 else if (aEvt.PropertyName.equals( "IsSpellUpperCase" )) 72 { 73 bSCWA = false == bVal; // FALSE->TRUE change? 74 bSWWA = !bSCWA; // TRUE->FALSE change? 75 } 76 else if (aEvt.PropertyName.equals( "IsSpellWithDigits" )) 77 { 78 bSCWA = false == bVal; // FALSE->TRUE change? 79 bSWWA = !bSCWA; // TRUE->FALSE change? 80 } 81 else if (aEvt.PropertyName.equals( "IsSpellCapitalization" )) 82 { 83 bSCWA = false == bVal; // FALSE->TRUE change? 84 bSWWA = !bSCWA; // TRUE->FALSE change? 85 } 86 87 if (bSCWA) 88 nLngSvcFlags |= LinguServiceEventFlags.SPELL_CORRECT_WORDS_AGAIN; 89 if (bSWWA) 90 nLngSvcFlags |= LinguServiceEventFlags.SPELL_WRONG_WORDS_AGAIN; 91 if (nLngSvcFlags != 0) 92 { 93 LinguServiceEvent aEvent = new LinguServiceEvent( GetEvtSource(), nLngSvcFlags ); 94 LaunchEvent( aEvent ); 95 } 96 } 97 } 98 }; 99 100