123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import com.sun.star.uno.*;
- import com.sun.star.awt.*;
- import com.sun.star.lang.*;
- import com.sun.star.beans.*;
- import com.sun.star.util.*;
- import com.sun.star.script.framework.browse.DialogFactory;
- ActionEvent event = (ActionEvent) ARGUMENTS[0];
- XButton button = (XButton)AnyConverter.toObject(
- new Type(XButton.class), event.Source);
- XControl control = (XControl)UnoRuntime.queryInterface(XControl.class, button);
- XControlModel cmodel = control.getModel();
- XPropertySet pset = (XPropertySet)UnoRuntime.queryInterface(
- XPropertySet.class, cmodel);
- if (pset.getPropertyValue("Label").equals("Exit"))
- {
-
-
- XDialog xDialog = (XDialog)UnoRuntime.queryInterface(
- XDialog.class, control.getContext());
-
-
- xDialog.endExecute();
- }
- else
- {
-
-
- XControlContainer controls = (XControlContainer)UnoRuntime.queryInterface(
- XControlContainer.class, control.getContext());
-
- XTextComponent textField = (XTextComponent)
- UnoRuntime.queryInterface(
- XTextComponent.class, controls.getControl("HighlightTextField"));
- String searchKey = textField.getText();
-
- java.awt.Color cRed = new java.awt.Color(255, 0, 0);
- int red = cRed.getRGB();
- XReplaceable replaceable = (XReplaceable)
- UnoRuntime.queryInterface(XReplaceable.class, XSCRIPTCONTEXT.getDocument());
- XReplaceDescriptor descriptor =
- (XReplaceDescriptor) replaceable.createReplaceDescriptor();
-
-
- XPropertyReplace xPropertyReplace = (XPropertyReplace)
- UnoRuntime.queryInterface(XPropertyReplace.class, descriptor);
-
- PropertyValue wv = new PropertyValue("CharWeight", -1,
- new Float(com.sun.star.awt.FontWeight.BOLD),
- com.sun.star.beans.PropertyState.DIRECT_VALUE);
-
- PropertyValue cv = new PropertyValue("CharColor", -1,
- new Integer(red),
- com.sun.star.beans.PropertyState.DIRECT_VALUE);
-
- PropertyValue[] props = new PropertyValue[] { cv, wv };
- try {
- xPropertyReplace.setReplaceAttributes(props);
-
- descriptor.setPropertyValue(
- "SearchCaseSensitive", new Boolean(true));
- descriptor.setPropertyValue("SearchWords", new Boolean(true));
- }
- catch (com.sun.star.beans.UnknownPropertyException upe) {
- System.err.println("Error setting up search properties");
- return;
- }
- catch (com.sun.star.beans.PropertyVetoException pve) {
- System.err.println("Error setting up search properties");
- return;
- }
- catch (com.sun.star.lang.WrappedTargetException wte) {
- System.err.println("Error setting up search properties");
- return;
- }
-
-
- descriptor.setSearchString(searchKey);
- descriptor.setReplaceString(searchKey);
- replaceable.replaceAll(descriptor);
- }
- return 0;
|