����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /proc/self/root/opt/libreoffice6.4/share/Scripts/beanshell/Highlight/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/opt/libreoffice6.4/share/Scripts/beanshell/Highlight/ButtonPressHandler.bsh
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
// this code is bound to the events generated by the buttons in the dialog
// it will close the dialog or find and highlight the text entered in the
// dialog (depending on the button pressed)
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;

// Get the ActionEvent object from the ARGUMENTS list
ActionEvent event = (ActionEvent) ARGUMENTS[0];

// Each argument is of type Any so we must use the AnyConverter class to
// convert it into the interface or primitive type we expect
XButton button = (XButton)AnyConverter.toObject(
    new Type(XButton.class), event.Source);

// We can now query for the model of the button and get its properties
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"))
{
    // We can get the XDialog in which this control appears by calling
    // getContext() on the XControl interface
    XDialog xDialog = (XDialog)UnoRuntime.queryInterface(
        XDialog.class, control.getContext());
    
    // Close the dialog
    xDialog.endExecute();
}
else
{
    // We can get the list of controls for this dialog by calling
    // getContext() on the XControl interface of the button
    XControlContainer controls = (XControlContainer)UnoRuntime.queryInterface(
        XControlContainer.class, control.getContext());

    // Now get the text field control from the list
    XTextComponent textField = (XTextComponent)
        UnoRuntime.queryInterface(
            XTextComponent.class, controls.getControl("HighlightTextField"));

    String searchKey = textField.getText();

    // highlight the text in red
    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();

    // Gets a XPropertyReplace object for altering the properties
    // of the replaced text
    XPropertyReplace xPropertyReplace = (XPropertyReplace)
        UnoRuntime.queryInterface(XPropertyReplace.class, descriptor);

    // Sets the replaced text property fontweight value to Bold
    PropertyValue wv = new PropertyValue("CharWeight", -1,
        new Float(com.sun.star.awt.FontWeight.BOLD),
            com.sun.star.beans.PropertyState.DIRECT_VALUE);

    // Sets the replaced text property color value to RGB parameter
    PropertyValue cv = new PropertyValue("CharColor", -1,
        new Integer(red),
            com.sun.star.beans.PropertyState.DIRECT_VALUE);

    // Apply the properties
    PropertyValue[] props = new PropertyValue[] { cv, wv }; 

    try {
        xPropertyReplace.setReplaceAttributes(props);

        // Only matches whole words and case sensitive
        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;
    }

    // Replaces all instances of searchKey with new Text properties
    // and gets the number of instances of the searchKey 
    descriptor.setSearchString(searchKey); 
    descriptor.setReplaceString(searchKey); 
    replaceable.replaceAll(descriptor);
}

// BeanShell scripts in LibreOffice should always return 0
return 0;

ZeroDay Forums Mini