Private
Server IP : 195.201.23.43  /  Your IP : 18.218.24.244
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/lib/libreoffice/share/Scripts/beanshell/MemoryUsage/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/self/root/lib/libreoffice/share/Scripts/beanshell/MemoryUsage/memusage.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 .
 */
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.document.XEmbeddedObjectSupplier;
import com.sun.star.awt.ActionEvent;
import com.sun.star.awt.Rectangle;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;

import com.sun.star.container.*;
import com.sun.star.chart.*;
import com.sun.star.table.*;
import com.sun.star.sheet.*;

import com.sun.star.script.provider.XScriptContext;

createSpreadsheet()
{
    loader = (XComponentLoader)
        UnoRuntime.queryInterface(
            XComponentLoader.class, XSCRIPTCONTEXT.getDesktop());

    comp = loader.loadComponentFromURL(
        "private:factory/scalc", "_blank", 4, new PropertyValue[0]);

    doc = (XSpreadsheetDocument)
        UnoRuntime.queryInterface(XSpreadsheetDocument.class, comp);

    index = (XIndexAccess)
        UnoRuntime.queryInterface(XIndexAccess.class, doc.getSheets());

    sheet = (XSpreadsheet) AnyConverter.toObject(
        new Type(com.sun.star.sheet.XSpreadsheet.class), index.getByIndex(0));

    return sheet;
}

addData(sheet, date, total, free)
{
    // set the labels
    sheet.getCellByPosition(0, 0).setFormula("Used");
    sheet.getCellByPosition(0, 1).setFormula("Free");
    sheet.getCellByPosition(0, 2).setFormula("Total");

    // set the values in the cells
    sheet.getCellByPosition(1, 0).setValue(total - free);
    sheet.getCellByPosition(1, 1).setValue(free);
    sheet.getCellByPosition(1, 2).setValue(total);
}

addChart(sheet)
{
    rect = new Rectangle();
    rect.X = 500;
    rect.Y = 3000;
    rect.Width = 10000;
    rect.Height = 8000;

    range = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, sheet);
    myRange = range.getCellRangeByName("A1:B2");

    rangeAddr = (XCellRangeAddressable)
        UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange);

    myAddr = rangeAddr.getRangeAddress();

    CellRangeAddress[] addr = new CellRangeAddress[1];
    addr[0] = myAddr;

    supp = (XTableChartsSupplier)
        UnoRuntime.queryInterface( XTableChartsSupplier.class, sheet);
    charts = supp.getCharts();
    charts.addNewByName("Example", rect, addr, false, true);

    try { Thread.sleep(3000); } catch (java.lang.InterruptedException e) { }

    // get the diagram and Change some of the properties
    chartsAccess = (XNameAccess)
        UnoRuntime.queryInterface( XNameAccess.class, charts);

    tchart = (XTableChart)
        UnoRuntime.queryInterface(
            XTableChart.class, chartsAccess.getByName("Example"));

    eos = (XEmbeddedObjectSupplier)
        UnoRuntime.queryInterface( XEmbeddedObjectSupplier.class, tchart );
    xifc = eos.getEmbeddedObject();

    xChart = (XChartDocument)
        UnoRuntime.queryInterface(XChartDocument.class, xifc);

    xDocMSF = (XMultiServiceFactory)
        UnoRuntime.queryInterface(XMultiServiceFactory.class, xChart);

    diagObject = xDocMSF.createInstance("com.sun.star.chart.PieDiagram");
    xDiagram = (XDiagram)
        UnoRuntime.queryInterface(XDiagram.class, diagObject);
    xChart.setDiagram(xDiagram);

    propset = (XPropertySet)
        UnoRuntime.queryInterface( XPropertySet.class, xChart.getTitle() );
    propset.setPropertyValue("String", "JVM Memory Usage");
}

runtime = Runtime.getRuntime();
generator = new Random();
date = new Date();

// allocate a random number of bytes so that the data changes
len = (int)(generator.nextFloat() * runtime.freeMemory() / 5);
bytes = new byte[len];

sheet = createSpreadsheet();
addData(sheet, date.toString(), runtime.totalMemory(), runtime.freeMemory());
addChart(sheet);

return 0;
Private