java: remove dead methods
found by UCDetector Change-Id: I219caa8e680dba5a395541a778df6144841c4dde
This commit is contained in:
parent
347926e8e5
commit
34bcf9b498
@ -27,7 +27,6 @@ $(eval $(call gb_Jar_add_sourcefiles,officebean,\
|
||||
bean/com/sun/star/beans/NativeConnection \
|
||||
bean/com/sun/star/beans/NativeService \
|
||||
bean/com/sun/star/beans/OfficeConnection \
|
||||
bean/com/sun/star/beans/OfficeWindow \
|
||||
bean/com/sun/star/comp/beans/ContainerFactory \
|
||||
bean/com/sun/star/comp/beans/Controller \
|
||||
bean/com/sun/star/comp/beans/Frame \
|
||||
|
@ -29,10 +29,5 @@ import java.awt.Container;
|
||||
|
||||
public interface ContainerFactory
|
||||
{
|
||||
/**
|
||||
* Creates an AWT container.
|
||||
*
|
||||
* @return An AWT container.
|
||||
*/
|
||||
Container createContainer();
|
||||
|
||||
}
|
||||
|
@ -158,19 +158,6 @@ public class LocalOfficeConnection
|
||||
return mContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an office window.
|
||||
* The window is either a sub-class of java.awt.Canvas (local) or
|
||||
* java.awt.Container (RVP).
|
||||
*
|
||||
* @param container This is an AWT container.
|
||||
* @return The office window instance.
|
||||
*/
|
||||
public OfficeWindow createOfficeWindow(Container container)
|
||||
{
|
||||
return new LocalOfficeWindow(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection.
|
||||
*/
|
||||
|
@ -42,7 +42,7 @@ import com.sun.star.uno.XComponentContext;
|
||||
*/
|
||||
public class LocalOfficeWindow
|
||||
extends java.awt.Canvas
|
||||
implements OfficeWindow, XEventListener
|
||||
implements XEventListener
|
||||
{
|
||||
private transient OfficeConnection mConnection;
|
||||
private transient XWindowPeer mParentProxy;
|
||||
|
@ -39,13 +39,7 @@ public interface OfficeConnection
|
||||
void setUnoUrl(String url)
|
||||
throws java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* Sets an AWT container catory.
|
||||
*
|
||||
* @param containerFactory This is a application provided AWT container
|
||||
* factory.
|
||||
*/
|
||||
void setContainerFactory(ContainerFactory containerFactory);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the UNO component context.
|
||||
@ -56,15 +50,5 @@ public interface OfficeConnection
|
||||
*/
|
||||
XComponentContext getComponentContext();
|
||||
|
||||
/**
|
||||
* Creates an office window.
|
||||
* The window is either a sub-class of java.awt.Canvas (local) or
|
||||
* java.awt.Container (RVP).
|
||||
*
|
||||
* This method does not add add the office window to its container.
|
||||
*
|
||||
* @param container This is an AWT container.
|
||||
* @return The office window instance.
|
||||
*/
|
||||
OfficeWindow createOfficeWindow(Container container);
|
||||
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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 .
|
||||
*/
|
||||
|
||||
package com.sun.star.beans;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import com.sun.star.awt.XWindowPeer;
|
||||
|
||||
/**
|
||||
* The concreate implementation of the OfficeWindow extends an
|
||||
* approperate type of visual component (java.awt.Canvas for local
|
||||
* and java.awt.Container for remote).
|
||||
* @deprecated
|
||||
*/
|
||||
public interface OfficeWindow
|
||||
{
|
||||
/**
|
||||
* Retrieves an AWT component object associated with the OfficeWindow.
|
||||
*
|
||||
* @return The AWT component object associated with the OfficeWindow.
|
||||
*/
|
||||
Component getAWTComponent();
|
||||
|
||||
/**
|
||||
* Retrieves an UNO XWindowPeer object associated with the OfficeWindow.
|
||||
*
|
||||
* @return The UNO XWindowPeer object associated with the OfficeWindow.
|
||||
*/
|
||||
XWindowPeer getUNOWindowPeer();
|
||||
}
|
@ -29,10 +29,5 @@ import java.awt.Container;
|
||||
|
||||
public interface ContainerFactory
|
||||
{
|
||||
/**
|
||||
* Creates an AWT container.
|
||||
*
|
||||
* @return An AWT container.
|
||||
*/
|
||||
Container createContainer();
|
||||
|
||||
}
|
||||
|
@ -83,13 +83,7 @@ public class Controller
|
||||
// com.sun.star.frame.XDispatchProvider
|
||||
|
||||
|
||||
public com.sun.star.frame.XDispatch queryDispatch(
|
||||
/*IN*/ com.sun.star.util.URL aURL,
|
||||
/*IN*/ String aTargetFrameName,
|
||||
/*IN*/ int nSearchFlags )
|
||||
{
|
||||
return xDispatchProvider.queryDispatch( aURL, aTargetFrameName, nSearchFlags );
|
||||
}
|
||||
|
||||
|
||||
public com.sun.star.frame.XDispatch[] queryDispatches(
|
||||
/*IN*/ com.sun.star.frame.DispatchDescriptor[] aRequests )
|
||||
|
@ -181,25 +181,7 @@ public class OOoBean
|
||||
xConnectionListener = this.new EventListener("setOOoConnection");
|
||||
}
|
||||
|
||||
// @requirement FUNC.CON.STRT/0.4
|
||||
/** Starts a connection to an OOo instance which is lauched if not running.
|
||||
|
||||
@throws HasConnectionException
|
||||
if a connection was already established.
|
||||
|
||||
@throws NoConnectionException
|
||||
if the specified connection cannot be established
|
||||
*/
|
||||
public void startOOoConnection( String aConnectionURL )
|
||||
throws java.net.MalformedURLException,
|
||||
HasConnectionException,
|
||||
NoConnectionException
|
||||
{
|
||||
// create a new connection from the given connection URL
|
||||
LocalOfficeConnection aConnection = new LocalOfficeConnection();
|
||||
aConnection.setUnoUrl( aConnectionURL );
|
||||
setOOoConnection( aConnection );
|
||||
}
|
||||
|
||||
// @requirement FUNC.CON.CHK/0.7
|
||||
/** Returns true if this OOoBean is connected to an OOo instance,
|
||||
@ -331,31 +313,7 @@ public class OOoBean
|
||||
return xDesktop;
|
||||
}
|
||||
|
||||
/** Resets this bean to an empty document.
|
||||
|
||||
If a document is loaded and the content modified,
|
||||
the changes are dismissed. Otherwise nothing happens.
|
||||
|
||||
This method is intended to be overridden in derived classes.
|
||||
This implementation simply calls clear.
|
||||
|
||||
@param bClearStateToo
|
||||
Not only the document content but also the state of the bean,
|
||||
like visibility of child components is cleared.
|
||||
|
||||
@deprecated There is currently no way to dismiss changes, except for loading
|
||||
of the unchanged initial document. Furthermore it is unclear how derived classes
|
||||
handle this and what exactly their state is (e.g. what members make up their state).
|
||||
Calling this method on a derived class requires knowledge about their implementation.
|
||||
Therefore a deriving class should declare their own clearDocument if needed. Clients
|
||||
should call the clearDocument of the deriving class or {@link #clear} which discards
|
||||
the currently displayed document.
|
||||
*/
|
||||
public synchronized void clearDocument( boolean bClearStateToo )
|
||||
{
|
||||
// TBD
|
||||
clear();
|
||||
}
|
||||
|
||||
/** Resets the OOoBean to an empty status.
|
||||
|
||||
@ -696,79 +654,9 @@ public class OOoBean
|
||||
}
|
||||
}
|
||||
|
||||
/** Loads a document from a Java stream.
|
||||
|
||||
See loadFromURL() for further information.
|
||||
*/
|
||||
public void loadFromStream(
|
||||
final java.io.InputStream iInStream,
|
||||
final com.sun.star.beans.PropertyValue aArguments[] )
|
||||
throws
|
||||
// @requirement FUNC.CON.LOST/0.2
|
||||
NoConnectionException,
|
||||
java.io.IOException,
|
||||
com.sun.star.lang.IllegalArgumentException,
|
||||
com.sun.star.util.CloseVetoException
|
||||
{
|
||||
// wrap Java stream into UNO stream
|
||||
|
||||
// copy stream....
|
||||
int s = 4096;
|
||||
int r=0 ,n = 0;
|
||||
byte[] buffer = new byte[s];
|
||||
byte[] newBuffer = null;
|
||||
while ((r = iInStream.read(buffer, n, buffer.length-n))>0) {
|
||||
n += r;
|
||||
if (iInStream.available() > buffer.length - n) {
|
||||
newBuffer = new byte[buffer.length*2];
|
||||
System.arraycopy(buffer, 0, newBuffer, 0, n);
|
||||
buffer = newBuffer;
|
||||
}
|
||||
}
|
||||
if (buffer.length != n) {
|
||||
newBuffer = new byte[n];
|
||||
System.arraycopy(buffer, 0, newBuffer, 0, n);
|
||||
buffer = newBuffer;
|
||||
}
|
||||
com.sun.star.io.XInputStream xStream =
|
||||
new com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter(buffer);
|
||||
|
||||
// add stream to arguments
|
||||
com.sun.star.beans.PropertyValue[] aExtendedArguments =
|
||||
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
|
||||
"InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
|
||||
|
||||
// call normal load method
|
||||
loadFromURL( "private:stream", aExtendedArguments );
|
||||
}
|
||||
|
||||
/** Loads a document from a byte array.
|
||||
|
||||
See loadFromURL() for further information.
|
||||
*/
|
||||
public void loadFromByteArray(
|
||||
final byte aInBuffer[],
|
||||
final com.sun.star.beans.PropertyValue aArguments[] )
|
||||
throws
|
||||
// @requirement FUNC.CON.LOST/0.2
|
||||
NoConnectionException,
|
||||
java.io.IOException,
|
||||
com.sun.star.lang.IllegalArgumentException,
|
||||
com.sun.star.util.CloseVetoException
|
||||
{
|
||||
// wrap byte arrray into UNO stream
|
||||
com.sun.star.io.XInputStream xStream =
|
||||
new com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter(
|
||||
aInBuffer );
|
||||
|
||||
// add stream to arguments
|
||||
com.sun.star.beans.PropertyValue[] aExtendedArguments =
|
||||
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
|
||||
"InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
|
||||
|
||||
// call normal load method
|
||||
loadFromURL( "private:stream", aExtendedArguments );
|
||||
}
|
||||
|
||||
/** Stores a document to the given URL.
|
||||
<p>
|
||||
@ -831,84 +719,9 @@ public class OOoBean
|
||||
{ throw new NoConnectionException(); }
|
||||
}
|
||||
|
||||
/** Stores a document to a stream.
|
||||
|
||||
See {@link #storeToURL storeToURL} for further information.
|
||||
@see #storeToURL storeToURL
|
||||
*/
|
||||
public java.io.OutputStream storeToStream(
|
||||
java.io.OutputStream aOutStream,
|
||||
final com.sun.star.beans.PropertyValue aArguments[] )
|
||||
throws
|
||||
// @requirement FUNC.CON.LOST/0.2
|
||||
NoConnectionException,
|
||||
NoDocumentException,
|
||||
java.io.IOException,
|
||||
com.sun.star.lang.IllegalArgumentException
|
||||
|
||||
{
|
||||
// wrap Java stream into UNO stream
|
||||
com.sun.star.lib.uno.adapter.OutputStreamToXOutputStreamAdapter aStream =
|
||||
new com.sun.star.lib.uno.adapter.OutputStreamToXOutputStreamAdapter(
|
||||
aOutStream );
|
||||
|
||||
// add stream to arguments
|
||||
com.sun.star.beans.PropertyValue[] aExtendedArguments =
|
||||
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
|
||||
"OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
|
||||
|
||||
// call normal store method
|
||||
storeToURL( "private:stream", aExtendedArguments );
|
||||
|
||||
// get byte array from document stream
|
||||
try { aStream.closeOutput(); }
|
||||
catch ( com.sun.star.io.NotConnectedException aExc )
|
||||
{ /* TDB */ }
|
||||
catch ( com.sun.star.io.BufferSizeExceededException aExc )
|
||||
{ /* TDB */ }
|
||||
catch ( com.sun.star.io.IOException aExc )
|
||||
{ throw new java.io.IOException(); }
|
||||
return aOutStream;
|
||||
}
|
||||
|
||||
/** Stores a document to a byte array.
|
||||
|
||||
See {@link #storeToURL storeToURL} for further information.
|
||||
@see #storeToURL storeToURL
|
||||
*/
|
||||
public byte[] storeToByteArray(
|
||||
byte aOutBuffer[],
|
||||
final com.sun.star.beans.PropertyValue aArguments[] )
|
||||
throws
|
||||
// @requirement FUNC.CON.LOST/0.2
|
||||
NoConnectionException,
|
||||
NoDocumentException,
|
||||
java.io.IOException,
|
||||
com.sun.star.lang.IllegalArgumentException
|
||||
{
|
||||
// wrap byte arrray into UNO stream
|
||||
com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter aStream =
|
||||
new com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter(
|
||||
aOutBuffer );
|
||||
|
||||
// add stream to arguments
|
||||
com.sun.star.beans.PropertyValue[] aExtendedArguments =
|
||||
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
|
||||
"OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
|
||||
|
||||
// call normal store method
|
||||
storeToURL( "private:stream", aExtendedArguments );
|
||||
|
||||
// get byte array from document stream
|
||||
try { aStream.closeOutput(); }
|
||||
catch ( com.sun.star.io.NotConnectedException aExc )
|
||||
{ /* TDB */ }
|
||||
catch ( com.sun.star.io.BufferSizeExceededException aExc )
|
||||
{ /* TDB */ }
|
||||
catch ( com.sun.star.io.IOException aExc )
|
||||
{ throw new java.io.IOException(); }
|
||||
return aStream.getBuffer();
|
||||
}
|
||||
|
||||
// @requirement FUNC.BEAN.PROG/0.5
|
||||
// @requirement API.SIM.SEAP/0.2
|
||||
|
@ -40,13 +40,7 @@ public interface OfficeConnection
|
||||
void setUnoUrl(String url)
|
||||
throws java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* Sets an AWT container catory.
|
||||
*
|
||||
* @param containerFactory This is a application provided AWT container
|
||||
* factory.
|
||||
*/
|
||||
void setContainerFactory(ContainerFactory containerFactory);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the UNO component context.
|
||||
|
@ -56,11 +56,11 @@ public class NativeStorageAccess {
|
||||
|
||||
public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException;
|
||||
|
||||
public native int readInt(String name,String key) throws java.io.IOException;
|
||||
|
||||
|
||||
public native void seek(String name,String key,long position) throws java.io.IOException;
|
||||
|
||||
public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException;
|
||||
|
||||
public native void writeInt(String name,String key,int v) throws java.io.IOException;
|
||||
|
||||
}
|
||||
|
@ -48,24 +48,6 @@ public class Connection
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
public boolean execute( final String _sql ) throws SQLException
|
||||
{
|
||||
XStatement statement = createStatement();
|
||||
return statement.execute( _sql );
|
||||
}
|
||||
|
||||
public XResultSet executeQuery( final String _sql ) throws SQLException
|
||||
{
|
||||
XStatement statement = createStatement();
|
||||
return statement.executeQuery( _sql );
|
||||
}
|
||||
|
||||
public int executeUpdate( final String _sql ) throws SQLException
|
||||
{
|
||||
XStatement statement = createStatement();
|
||||
return statement.executeUpdate( _sql );
|
||||
}
|
||||
|
||||
public void refreshTables()
|
||||
{
|
||||
final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_connection);
|
||||
|
@ -50,10 +50,7 @@ public class MethodHandler implements XPropertyHandler
|
||||
}
|
||||
}
|
||||
|
||||
static public XSingleComponentFactory getFactory()
|
||||
{
|
||||
return new ComponentFactory( MethodHandler.class );
|
||||
}
|
||||
|
||||
|
||||
public void actuatingPropertyChanged(String _propertyName, Object _newValue, Object _oldValue, com.sun.star.inspection.XObjectInspectorUI _objectInspectorUI, boolean _firstTimeInit) throws com.sun.star.lang.NullPointerException
|
||||
{
|
||||
|
@ -179,10 +179,7 @@ public class CheckOGroupBoxModel
|
||||
return propertiesChanged;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
propertiesChanged = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private XMultiServiceFactory getMSF()
|
||||
|
@ -108,11 +108,7 @@ public class DocumentHelper
|
||||
return blankDocument( orb, DocumentType.WRITER );
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public static DocumentHelper blankXMLForm( XMultiServiceFactory orb ) throws com.sun.star.uno.Exception
|
||||
{
|
||||
return blankDocument( orb, DocumentType.XMLFORM );
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public static DocumentHelper blankDocument( XMultiServiceFactory orb, DocumentType eType ) throws com.sun.star.uno.Exception
|
||||
@ -260,22 +256,7 @@ public class DocumentHelper
|
||||
return createSubForm( xContainer, sInitialName );
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves the document model which a given form component belongs to
|
||||
*/
|
||||
static public DocumentHelper getDocumentForComponent( Object aFormComponent, XMultiServiceFactory orb )
|
||||
{
|
||||
XChild xChild = UnoRuntime.queryInterface( XChild.class, aFormComponent );
|
||||
XModel xModel = null;
|
||||
while ( ( null != xChild ) && ( null == xModel ) )
|
||||
{
|
||||
XInterface xParent = (XInterface)xChild.getParent();
|
||||
xModel = UnoRuntime.queryInterface( XModel.class, xParent );
|
||||
xChild = UnoRuntime.queryInterface( XChild.class, xParent );
|
||||
}
|
||||
|
||||
return new DocumentHelper( orb, xModel );
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** returns a URL which can be used to create a document of a certain type
|
||||
|
@ -26,10 +26,7 @@ public class DocumentType extends com.sun.star.uno.Enum
|
||||
super( value );
|
||||
}
|
||||
|
||||
public static DocumentType getDefault()
|
||||
{
|
||||
return WRITER;
|
||||
}
|
||||
|
||||
|
||||
public static final DocumentType WRITER = new DocumentType(0);
|
||||
public static final DocumentType CALC = new DocumentType(1);
|
||||
@ -37,16 +34,6 @@ public class DocumentType extends com.sun.star.uno.Enum
|
||||
public static final DocumentType XMLFORM = new DocumentType(3);
|
||||
public static final DocumentType UNKNOWN = new DocumentType(-1);
|
||||
|
||||
public static DocumentType fromInt(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case 0: return WRITER;
|
||||
case 1: return CALC;
|
||||
case 2: return DRAWING;
|
||||
case 3: return XMLFORM;
|
||||
default: return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -213,36 +213,6 @@ public class DocumentViewHelper
|
||||
xControlWindow.setFocus();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** sets the focus to the first control
|
||||
*/
|
||||
protected void grabControlFocus( ) throws java.lang.Exception
|
||||
{
|
||||
// the forms container of our document
|
||||
XIndexContainer xForms = dbfTools.queryIndexContainer( m_document.getFormComponentTreeRoot( ) );
|
||||
// the first form
|
||||
XIndexContainer xForm = dbfTools.queryIndexContainer( xForms.getByIndex( 0 ) );
|
||||
|
||||
// the first control model which is no FixedText (FixedText's can't have the focus)
|
||||
for ( int i = 0; i<xForm.getCount(); ++i )
|
||||
{
|
||||
XPropertySet xControlProps = dbfTools.queryPropertySet( xForm.getByIndex( i ) );
|
||||
if ( FormComponentType.FIXEDTEXT != ((Short)xControlProps.getPropertyValue( "ClassId" )).shortValue() )
|
||||
{
|
||||
XControlModel xControlModel = UnoRuntime.queryInterface(
|
||||
XControlModel.class, xControlProps );
|
||||
// set the focus to this control
|
||||
grabControlFocus( xControlModel );
|
||||
// outta here
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Note that we simply took the first control model from the hierarchy. This does state nothing
|
||||
// about the location of the respective control in the view. A control model is tied to a control
|
||||
// shape, and the shapes are where the geometry information such as position and size is hung up.
|
||||
// So you could easily have a document where the first control model is bound to a shape which
|
||||
// has a greater ordinate than any other control model.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,13 +108,7 @@ public class FormComponent
|
||||
return new String[]{};
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public boolean hasByName( String name )
|
||||
{
|
||||
if ( m_nameAccess != null )
|
||||
return m_nameAccess.hasByName( name );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public int getCount()
|
||||
@ -150,15 +144,7 @@ public class FormComponent
|
||||
return new com.sun.star.uno.Type( String.class );
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public boolean hasElements()
|
||||
{
|
||||
if ( m_indexAccess != null )
|
||||
return m_indexAccess.hasElements();
|
||||
else if ( m_nameAccess != null )
|
||||
return m_nameAccess.hasElements();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public FormComponent getParent()
|
||||
|
@ -276,29 +276,7 @@ public class FormLayer
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves the radio button model with the given name and the given tag
|
||||
* @param form
|
||||
* the parent form of the radio button model to find
|
||||
* @param name
|
||||
* the name of the radio button
|
||||
* @param tag
|
||||
* the tag of the radio button
|
||||
*/
|
||||
public XPropertySet getRadioModelByTag( XPropertySet form, String name, String tag ) throws com.sun.star.uno.Exception, java.lang.Exception
|
||||
{
|
||||
XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form );
|
||||
|
||||
for ( int i=0; i<indexAccess.getCount(); ++i )
|
||||
{
|
||||
XPropertySet control = dbfTools.queryPropertySet( indexAccess.getByIndex( i ) );
|
||||
|
||||
if ( ((String)control.getPropertyValue( "Name" )).equals( name ) )
|
||||
if ( ((String)control.getPropertyValue( "Tag" )).equals( tag ) )
|
||||
return control;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves a control model with a given (integer) access path
|
||||
@ -320,24 +298,7 @@ public class FormLayer
|
||||
return controlModel;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves a control model with a given (string) access path
|
||||
*/
|
||||
public XPropertySet getControlModel( String[] _accessPath ) throws com.sun.star.uno.Exception
|
||||
{
|
||||
XNameAccess nameAcc = m_document.getFormComponentTreeRoot();
|
||||
XPropertySet controlModel = null;
|
||||
int i=0;
|
||||
while ( ( nameAcc != null ) && ( i < _accessPath.length ) )
|
||||
{
|
||||
controlModel = UnoRuntime.queryInterface( XPropertySet.class,
|
||||
nameAcc.getByName( _accessPath[i] ) );
|
||||
nameAcc = UnoRuntime.queryInterface( XNameAccess.class,
|
||||
controlModel );
|
||||
++i;
|
||||
}
|
||||
return controlModel;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** simulates a user's text input into a control given by control model
|
||||
|
@ -47,18 +47,7 @@ public class Instance
|
||||
return createElement( m_domInstance, _elementName, null );
|
||||
}
|
||||
|
||||
/** creates a new element in the instance
|
||||
*
|
||||
* The element will be inserted immediately below a given XNode.
|
||||
*
|
||||
* @param _parentElement the node whose child shall be created
|
||||
* @param _elementName the name of the to-be-created element
|
||||
* @return the node of the newly created element
|
||||
*/
|
||||
public XNode createElement( XNode _parentElement, String _elementName ) throws DOMException
|
||||
{
|
||||
return createElement( _parentElement, _elementName, null );
|
||||
}
|
||||
|
||||
|
||||
/** creates a new element in the instance
|
||||
*
|
||||
@ -115,31 +104,9 @@ public class Instance
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
/** creates an attribute for the root node of the instance
|
||||
*
|
||||
* @param _attribName
|
||||
* the name of the to-be-created attribute
|
||||
* @return
|
||||
* the DOM node, which has already been inserted into the DOM tree
|
||||
*/
|
||||
public XNode createAttribute( String _attribName ) throws DOMException
|
||||
{
|
||||
return createAttribute( m_domInstance, _attribName, null );
|
||||
}
|
||||
|
||||
/** creates an attribute for the root node of the instance
|
||||
*
|
||||
* @param _attribName
|
||||
* the name of the to-be-created attribute
|
||||
* @param _initialNodeValue
|
||||
* the initial value to set at the node. Might be null, in this case no value is set.
|
||||
* @return
|
||||
* the DOM node, which has already been inserted into the DOM tree
|
||||
*/
|
||||
public XNode createAttribute( String _attribName, String _initialNodeValue ) throws DOMException
|
||||
{
|
||||
return createAttribute( m_domInstance, _attribName, _initialNodeValue );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** creates an attribute for the given node
|
||||
*
|
||||
|
@ -38,10 +38,7 @@ public class Model
|
||||
m_model );
|
||||
}
|
||||
|
||||
protected XModel getXModel()
|
||||
{
|
||||
return m_model;
|
||||
}
|
||||
|
||||
|
||||
protected XFormsUIHelper1 getUIHelper()
|
||||
{
|
||||
|
@ -61,20 +61,7 @@ class ConfigHelper
|
||||
}
|
||||
|
||||
|
||||
public Object readRelativeKey(String sRelPath,
|
||||
String sKey )
|
||||
throws com.sun.star.container.NoSuchElementException
|
||||
{
|
||||
try
|
||||
{
|
||||
XPropertySet xPath = UnoRuntime.queryInterface(XPropertySet.class, m_xConfig.getByHierarchicalName(sRelPath));
|
||||
return xPath.getPropertyValue(sKey);
|
||||
}
|
||||
catch(com.sun.star.uno.Exception ex)
|
||||
{
|
||||
throw new com.sun.star.container.NoSuchElementException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void writeRelativeKey(String sRelPath,
|
||||
|
@ -473,24 +473,7 @@ public class Protocol extends JComponent
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For some modes it's necessary, that we write some additional
|
||||
* information to the log. E.g. for html we must generate close targets.
|
||||
*/
|
||||
public synchronized void finish()
|
||||
{
|
||||
// Preferr HTML ... because we can't write ASCII and HTML contents to the same log file!
|
||||
String sContent;
|
||||
if ((m_nMode & MODE_HTML) == MODE_HTML)
|
||||
sContent = impl_generateHTMLFooter();
|
||||
else
|
||||
if ((m_nMode & MODE_ASCII) == MODE_ASCII)
|
||||
sContent = impl_generateAsciiFooter();
|
||||
else
|
||||
return;
|
||||
|
||||
impl_writeToLogFile(m_sFileName, true, sContent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -533,47 +516,13 @@ public class Protocol extends JComponent
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* log different property arrays.
|
||||
*
|
||||
* @param lProps
|
||||
* the array of properties
|
||||
*/
|
||||
public synchronized void log( /*IN*/ com.sun.star.beans.NamedValue[] lProps )
|
||||
{
|
||||
StringBuffer sValues = new StringBuffer(1000);
|
||||
impl_logPropertyArray(sValues, lProps);
|
||||
|
||||
log(TYPE_SCOPE_OPEN | TYPE_INFO, "property array ["+lProps.length+"]:");
|
||||
log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValues.toString() );
|
||||
}
|
||||
|
||||
public synchronized void log( /*IN*/ com.sun.star.beans.PropertyValue[] lProps )
|
||||
{
|
||||
StringBuffer sValues = new StringBuffer(1000);
|
||||
impl_logPropertyArray(sValues, lProps);
|
||||
|
||||
log(TYPE_SCOPE_OPEN | TYPE_INFO, "property array ["+lProps.length+"]:");
|
||||
log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValues.toString() );
|
||||
}
|
||||
|
||||
public synchronized void log( /*IN*/ com.sun.star.beans.NamedValue aProp )
|
||||
{
|
||||
StringBuffer sValue = new StringBuffer(1000);
|
||||
impl_logProperty(sValue, aProp);
|
||||
|
||||
log(TYPE_SCOPE_OPEN | TYPE_INFO, "property:" );
|
||||
log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValue.toString());
|
||||
}
|
||||
|
||||
public synchronized void log( /*IN*/ com.sun.star.beans.PropertyValue aProp )
|
||||
{
|
||||
StringBuffer sValue = new StringBuffer(1000);
|
||||
impl_logProperty(sValue, aProp);
|
||||
|
||||
log(TYPE_SCOPE_OPEN | TYPE_INFO, "property:" );
|
||||
log(TYPE_SCOPE_CLOSE | TYPE_INFO, sValue.toString());
|
||||
}
|
||||
|
||||
public synchronized void log( /*IN*/ Object aAny )
|
||||
{
|
||||
@ -672,21 +621,7 @@ public class Protocol extends JComponent
|
||||
}
|
||||
|
||||
|
||||
public synchronized void defineHyperlink( /*IN*/ String sTarget ,
|
||||
/*IN*/ String sDescription)
|
||||
{
|
||||
if ((m_nMode & MODE_HTML) != MODE_HTML)
|
||||
return;
|
||||
|
||||
StringBuffer sLog = new StringBuffer(1000);
|
||||
sLog.append("<a href=\"");
|
||||
sLog.append(sTarget );
|
||||
sLog.append("\">" );
|
||||
sLog.append(sDescription);
|
||||
sLog.append("</a>" );
|
||||
|
||||
log(TYPE_LINK, sLog.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -191,30 +191,7 @@ public class RecoveryTools {
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* This function close the office while calling terminate on the desktop. If
|
||||
* this failed, the <CODE>ProcessHandler</CODE> kills the process.
|
||||
* @param xMSF the <CODE>XMultiServiceFactory</CODE>
|
||||
* @return <CODE>TRUE</CODE> if no exception was thrown, otherwise <CODE>FALSE</CODE>
|
||||
*/
|
||||
public boolean closeOffice(XMultiServiceFactory xMSF) {
|
||||
try {
|
||||
XDesktop desk = UnoRuntime.queryInterface(
|
||||
XDesktop.class, xMSF.createInstance(
|
||||
"com.sun.star.frame.Desktop"));
|
||||
xMSF = null;
|
||||
|
||||
desk.terminate();
|
||||
log.println("Waiting until ProcessHandler loses the office...");
|
||||
|
||||
}
|
||||
catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
waitForClosedOffice();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function waits until the office is closed. If the closing time reach
|
||||
@ -237,10 +214,7 @@ public class RecoveryTools {
|
||||
if (ph != null) ph.kill();
|
||||
}
|
||||
|
||||
public void killOffice(){
|
||||
helper.ProcessHandler ph = (helper.ProcessHandler) param.get("AppProvider");
|
||||
ph.kill();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The office must be started WITH restore and crashreporter functionality.
|
||||
|
@ -64,21 +64,7 @@ public class BasicBound {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static BasicBound getBound(double[] data) {
|
||||
BasicBound bound = new BasicBound();
|
||||
if(data!=null) {
|
||||
if(data.length>0) {
|
||||
bound.minValue = data[0];
|
||||
bound.maxValue = data[0];
|
||||
for(int i=1; i<data.length; i++) {
|
||||
bound.minValue = Math.min(bound.minValue, data[i]);
|
||||
bound.maxValue = Math.max(bound.maxValue, data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return bound;
|
||||
}
|
||||
|
||||
public double randomAdjust (double value){
|
||||
if(value > maxValue || value < minValue) {
|
||||
|
@ -26,19 +26,5 @@ public class GlobalCompare {
|
||||
return CompareValue.EQUAL_TO;
|
||||
}
|
||||
|
||||
/* check the magnitude of two array, the frontial is more important
|
||||
**/
|
||||
public static int compareArray(double[] fit1, double[] fit2) {
|
||||
if (fit1.length!=fit2.length) {
|
||||
return CompareValue.INVALID; //error
|
||||
}
|
||||
for (int i=0; i<fit1.length; i++) {
|
||||
if (fit1[i]>fit2[i]) {
|
||||
return CompareValue.LARGER_THAN; //Large than
|
||||
} else if (fit1[i]<fit2[i]){
|
||||
return CompareValue.LESS_THAN; //Less than
|
||||
}
|
||||
}
|
||||
return CompareValue.EQUAL_TO; //same
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,13 +45,9 @@ public class GlobalString {
|
||||
return v.toArray(new String[v.size()]);
|
||||
}
|
||||
|
||||
public static String[] getMeaningfulLines(String srcStr) throws Exception {
|
||||
return getMeaningfulLines(srcStr, NEGLECT_TAG);
|
||||
}
|
||||
|
||||
public static String getMeaningfulLine(BufferedReader outReader) throws Exception {
|
||||
return getMeaningfulLine(outReader, NEGLECT_TAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static int getCharLoc(char data, String str) {
|
||||
for(int i=0; i<str.length(); i++) {
|
||||
@ -126,18 +122,8 @@ public class GlobalString {
|
||||
return nObj.toString();
|
||||
}
|
||||
|
||||
static public int toInteger(Object oVal) throws Exception {
|
||||
if(oVal==null) throw new Exception("Null string");
|
||||
return Integer.parseInt(oVal.toString());
|
||||
}
|
||||
|
||||
static public double toDouble(Object oVal) throws Exception {
|
||||
if(oVal==null) throw new Exception("Null string");
|
||||
return Double.parseDouble(oVal.toString());
|
||||
}
|
||||
|
||||
public static Object toObject(String key) throws Exception{
|
||||
Class cls = Class.forName(key);
|
||||
return cls.newInstance();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -28,18 +28,7 @@ public class OutputMethods {
|
||||
public OutputMethods() {
|
||||
}
|
||||
|
||||
public static String outputVectorAsStr(double[] vector){
|
||||
if(vector==null) return "NULL";
|
||||
String totalStr = "";
|
||||
for(int i=0;i<vector.length;i++){
|
||||
totalStr += vector[i];
|
||||
if(i!=vector.length-1) {
|
||||
totalStr += "\t";
|
||||
}
|
||||
}
|
||||
totalStr+="\r\n";
|
||||
return totalStr;
|
||||
}
|
||||
|
||||
|
||||
public static void outputVector(double[] vector){
|
||||
for(int i=0;i<vector.length;i++){
|
||||
|
@ -45,49 +45,13 @@ public static double doubleRangeRandom(double lowLimit,double upLimit){
|
||||
return(num);
|
||||
}
|
||||
|
||||
/**This function returns true or false with a random probability.
|
||||
* @return int return value
|
||||
*/
|
||||
public static boolean booleanRandom(){
|
||||
boolean value = true;
|
||||
double temp=Math.random();
|
||||
if (temp<0.5) value=false;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int[] randomSelection(boolean[] types, int times) {
|
||||
int validNum = 0;
|
||||
for(int i=0; i<types.length; i++) {
|
||||
if(!types[i]) {
|
||||
validNum++;
|
||||
}
|
||||
}
|
||||
int[] totalIndices = new int[validNum];
|
||||
validNum = 0;
|
||||
for(int i=0; i<types.length; i++) {
|
||||
if(!types[i]) {
|
||||
totalIndices[validNum] = i;
|
||||
validNum++;
|
||||
if(validNum==totalIndices.length) break;
|
||||
}
|
||||
}
|
||||
return randomSelection(totalIndices, times);
|
||||
}
|
||||
|
||||
public static int[] randomSelection(int low, int up, int times){
|
||||
int[] totalIndices = new int[up-low];
|
||||
for (int i=low; i<up; i++) {
|
||||
totalIndices[i] = i;
|
||||
}
|
||||
return randomSelection(totalIndices, times);
|
||||
}
|
||||
|
||||
public static int getRealV(double randTypeV) {
|
||||
if(randTypeV<=0) return 0;
|
||||
int realV = (int)Math.ceil(randTypeV);
|
||||
if(Math.random()<(randTypeV-realV)) realV++;
|
||||
return realV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static int[] randomSelection(int[] totalIndices, int times) {
|
||||
if (times>=totalIndices.length) {
|
||||
|
@ -68,10 +68,5 @@ public class SearchPoint extends BasicPoint implements IEncodeEngine {
|
||||
return encodeInfo[0] == 0; //no constraint violations
|
||||
}
|
||||
|
||||
public void outputSelf() {
|
||||
System.out.println("#--> Location:");
|
||||
OutputMethods.outputVector(getLocation());
|
||||
System.out.println("#--> (CON & OPTIM):");
|
||||
OutputMethods.outputVector(getEncodeInfo());
|
||||
}
|
||||
|
||||
}
|
@ -65,11 +65,7 @@ public abstract class ProblemEncoder {
|
||||
designSpace.setElemAt(dd, i);
|
||||
}
|
||||
|
||||
protected void setDefaultXAt(int i, double min, double max) {
|
||||
DesignDim dd = new DesignDim();
|
||||
dd.paramBound = new BasicBound(min, max);
|
||||
designSpace.setElemAt(dd, i);
|
||||
}
|
||||
|
||||
|
||||
//set the default information for evaluation each response
|
||||
protected void setDefaultYAt(int i, double min, double max) {
|
||||
@ -78,12 +74,7 @@ public abstract class ProblemEncoder {
|
||||
evalStruct.setElemAt(ee, i);
|
||||
}
|
||||
|
||||
protected void setDefaultYAt(int i, double min, double max, double weight) {
|
||||
EvalElement ee = new EvalElement();
|
||||
ee.targetBound = new BasicBound(min, max);
|
||||
ee.weight = weight;
|
||||
evalStruct.setElemAt(ee, i);
|
||||
}
|
||||
|
||||
|
||||
//get a fresh point
|
||||
public SearchPoint getFreshSearchPoint() {
|
||||
|
@ -29,10 +29,7 @@ public class DesignDim {
|
||||
public BasicBound paramBound = new BasicBound(); //the range of a parameter
|
||||
|
||||
|
||||
public void importData(DesignDim ipr) {
|
||||
this.grain = ipr.grain;
|
||||
this.paramBound = ipr.paramBound;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDiscrete() {
|
||||
return grain!=0;
|
||||
|
@ -35,9 +35,7 @@ public class DesignSpace {
|
||||
dimProps = new DesignDim[dim];
|
||||
}
|
||||
|
||||
public DesignDim getDimAt(int index) {
|
||||
return dimProps[index];
|
||||
}
|
||||
|
||||
|
||||
public void setElemAt(DesignDim elem, int index) {
|
||||
dimProps[index] = elem;
|
||||
@ -60,56 +58,26 @@ public class DesignSpace {
|
||||
}
|
||||
}
|
||||
|
||||
public void randomAdjust (double[] location){
|
||||
for (int i=0; i<getDimension(); i++) {
|
||||
location[i] = dimProps[i].paramBound.randomAdjust(location[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean satisfyCondition(double[] location){
|
||||
for (int i=0; i<getDimension(); i++) {
|
||||
if (!dimProps[i].paramBound.isSatisfyCondition(location[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*If the limits are not violated, return TRUE*/
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void mutationAt(double[] location, int i){
|
||||
location[i] = dimProps[i].paramBound.getRandomValue();
|
||||
}
|
||||
|
||||
public double mutationUniformAtPointAsCenter (double pointX, int i){
|
||||
double length = this.getMagnitudeIn(i)/2;
|
||||
pointX += RandomGenerator.doubleRangeRandom(-1*length, length);
|
||||
|
||||
return pointX;
|
||||
}
|
||||
|
||||
public double getUpValueAt(int dimensionIndex) {
|
||||
return dimProps[dimensionIndex].paramBound.maxValue;
|
||||
}
|
||||
|
||||
public double getLowValueAt(int dimensionIndex) {
|
||||
return dimProps[dimensionIndex].paramBound.minValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double getMagnitudeIn(int dimensionIndex) {
|
||||
return dimProps[dimensionIndex].paramBound.getLength();
|
||||
}
|
||||
|
||||
|
||||
public boolean initilizeGeneAtPointAsCenter(double[] tempX){
|
||||
if (tempX.length!=this.getDimension()) {
|
||||
return false;
|
||||
}
|
||||
for(int i=0;i<tempX.length;i++) {
|
||||
double length = this.getMagnitudeIn(i)/2;
|
||||
tempX[i]+=RandomGenerator.doubleRangeRandom(-1*length, length);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void initializeGene(double[] tempX){
|
||||
for(int i=0;i<tempX.length;i++) tempX[i] = dimProps[i].paramBound.getRandomValue(); //Global.RandomGenerator.doubleRangeRandom(9.8, 10);
|
||||
@ -129,11 +97,5 @@ public class DesignSpace {
|
||||
}
|
||||
}
|
||||
|
||||
public double[] getRealLoc(double[] imageLoc) {
|
||||
double[] realLoc = new double[imageLoc.length];
|
||||
System.arraycopy(imageLoc, 0, realLoc, 0, imageLoc.length);
|
||||
annulusAdjust(realLoc);
|
||||
return realLoc;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,10 +360,7 @@ public abstract class BaseNLPSolver extends WeakBase
|
||||
return null;
|
||||
}
|
||||
|
||||
protected XCellRangeData getCellRangeData(CellRangeAddress cellRangeAddress) {
|
||||
return getCellRangeData(cellRangeAddress.Sheet, cellRangeAddress.StartColumn,
|
||||
cellRangeAddress.StartRow, cellRangeAddress.EndColumn, cellRangeAddress.EndRow);
|
||||
}
|
||||
|
||||
|
||||
private XCellRangeData getCellRangeData(int sheet, int startCol, int startRow, int endCol, int endRow) {
|
||||
try {
|
||||
|
@ -142,16 +142,9 @@ public abstract class BaseDialog extends BaseControl {
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
public ModalState showModal() {
|
||||
xWindow.setVisible(true);
|
||||
xDialog.execute();
|
||||
return modalState;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
xDialog.endExecute();
|
||||
xWindow.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setCloseable(boolean closeable) {
|
||||
setProperty("Closeable", new Boolean(closeable));
|
||||
|
@ -81,10 +81,7 @@ public class Helper
|
||||
|
||||
|
||||
|
||||
public XModel createPresentationDocument()
|
||||
{
|
||||
return createDocument( "simpress" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -91,79 +91,13 @@ public class DialogComponent {
|
||||
}
|
||||
}
|
||||
|
||||
// XTestDialogHandler
|
||||
public String createDialog( String DialogURL, XModel xModel, XFrame xFrame ) {
|
||||
m_xFrame = xFrame;
|
||||
|
||||
try {
|
||||
XMultiComponentFactory xMCF = m_xCmpCtx.getServiceManager();
|
||||
Object obj;
|
||||
|
||||
// If valid we must pass the XModel when creating a DialogProvider object
|
||||
if( xModel != null ) {
|
||||
Object[] args = new Object[1];
|
||||
args[0] = xModel;
|
||||
|
||||
obj = xMCF.createInstanceWithArgumentsAndContext(
|
||||
"com.sun.star.awt.DialogProvider2", args, m_xCmpCtx );
|
||||
}
|
||||
else {
|
||||
obj = xMCF.createInstanceWithContext(
|
||||
"com.sun.star.awt.DialogProvider2", m_xCmpCtx );
|
||||
}
|
||||
|
||||
XDialogProvider2 xDialogProvider = UnoRuntime.queryInterface( XDialogProvider2.class, obj );
|
||||
|
||||
XDialog xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this );
|
||||
if( xDialog != null )
|
||||
xDialog.execute();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "Created dialog \"" + DialogURL + "\"";
|
||||
}
|
||||
|
||||
public void copyText( XDialog xDialog ) {
|
||||
XControlContainer xControlContainer = UnoRuntime.queryInterface(
|
||||
XControlContainer.class, xDialog );
|
||||
String aTextPropertyStr = "Text";
|
||||
String aText = "";
|
||||
XControl xTextField1Control = xControlContainer.getControl( "TextField1" );
|
||||
XControlModel xControlModel1 = xTextField1Control.getModel();
|
||||
XPropertySet xPropertySet1 = UnoRuntime.queryInterface(
|
||||
XPropertySet.class, xControlModel1 );
|
||||
try
|
||||
{
|
||||
aText = (String)xPropertySet1.getPropertyValue( aTextPropertyStr );
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
XControl xTextField2Control = xControlContainer.getControl( "TextField2" );
|
||||
XControlModel xControlModel2 = xTextField2Control.getModel();
|
||||
XPropertySet xPropertySet2 = UnoRuntime.queryInterface(
|
||||
XPropertySet.class, xControlModel2 );
|
||||
try
|
||||
{
|
||||
xPropertySet2.setPropertyValue( aTextPropertyStr, aText );
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
showMessageBox( "DialogComponent", "copyText() called" );
|
||||
}
|
||||
|
||||
public void handleEvent() {
|
||||
showMessageBox( "DialogComponent", "handleEvent() called" );
|
||||
}
|
||||
|
||||
public void handleEventWithArguments( XDialog xDialog, Object aEventObject ) {
|
||||
showMessageBox( "DialogComponent", "handleEventWithArguments() called\n\n" +
|
||||
"Event Object = " + aEventObject );
|
||||
}
|
||||
|
||||
private final String aHandlerMethod1 = "doit1";
|
||||
private final String aHandlerMethod2 = "doit2";
|
||||
|
@ -74,17 +74,7 @@ public class RowSet
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void printDataSources() throws com.sun.star.uno.Exception
|
||||
{
|
||||
// create a DatabaseContext and print all DataSource names
|
||||
XNameAccess xNameAccess = UnoRuntime.queryInterface(
|
||||
XNameAccess.class,
|
||||
xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
|
||||
xContext));
|
||||
String aNames [] = xNameAccess.getElementNames();
|
||||
for(int i=0;i<aNames.length;++i)
|
||||
System.out.println(aNames[i]);
|
||||
}
|
||||
|
||||
|
||||
private static void useRowSet() throws com.sun.star.uno.Exception
|
||||
{
|
||||
|
@ -106,40 +106,7 @@ public class Sales
|
||||
}
|
||||
}
|
||||
|
||||
// create a scrollable resultset.
|
||||
public void retrieveSalesData2() throws com.sun.star.uno.Exception
|
||||
{
|
||||
// example for a programmatic way to do updates.
|
||||
XStatement stmt = con.createStatement();
|
||||
XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,stmt);
|
||||
|
||||
xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
|
||||
xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.UPDATABLE));
|
||||
|
||||
XResultSet srs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
|
||||
XRow row = UnoRuntime.queryInterface(XRow.class,srs);
|
||||
|
||||
srs.afterLast();
|
||||
while (srs.previous()) {
|
||||
String name = row.getString(1);
|
||||
float price = row.getFloat(2);
|
||||
System.out.println(name + " " + price);
|
||||
}
|
||||
|
||||
srs.last();
|
||||
XRowUpdate updateRow = UnoRuntime.queryInterface(XRowUpdate.class,srs);
|
||||
updateRow.updateFloat(2, (float)0.69);
|
||||
|
||||
XResultSetUpdate updateRs = UnoRuntime.queryInterface(
|
||||
XResultSetUpdate.class,srs);
|
||||
updateRs.updateRow(); // this call updates the data in DBMS
|
||||
|
||||
srs.last();
|
||||
updateRow.updateFloat(2, (float)0.99);
|
||||
updateRs.cancelRowUpdates();
|
||||
updateRow.updateFloat(2, (float)0.79);
|
||||
updateRs.updateRow();
|
||||
}
|
||||
|
||||
// inserts a row programmatically.
|
||||
private void insertRow() throws com.sun.star.uno.Exception
|
||||
@ -186,38 +153,7 @@ public class Sales
|
||||
updateRs.deleteRow();
|
||||
}
|
||||
|
||||
// refresh a row
|
||||
public void refreshRow() throws com.sun.star.uno.Exception
|
||||
{
|
||||
// example for a programmatic way to do updates.
|
||||
// first we need the 4 row
|
||||
insertRow();
|
||||
|
||||
XStatement stmt = con.createStatement();
|
||||
XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,stmt);
|
||||
xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
|
||||
xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.READ_ONLY));
|
||||
XResultSet rs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
|
||||
XRow row = UnoRuntime.queryInterface(XRow.class, rs);
|
||||
rs.absolute(4);
|
||||
float price1 = row.getFloat(2);
|
||||
|
||||
// modifiy the 4 row
|
||||
XRowUpdate updateRow = UnoRuntime.queryInterface(XRowUpdate.class,rs);
|
||||
XResultSetUpdate updateRs = UnoRuntime. queryInterface(XResultSetUpdate.class,rs);
|
||||
updateRow.updateFloat(2, 150);
|
||||
updateRs.updateRow();
|
||||
// repositioning
|
||||
rs.absolute(4);
|
||||
rs.refreshRow();
|
||||
float price2 = row.getFloat(2);
|
||||
if (price2 != price1) {
|
||||
System.out.println("Prices are different.");
|
||||
}
|
||||
else
|
||||
System.out.println("Prices are equal.");
|
||||
deleteRow();
|
||||
}
|
||||
|
||||
// displays the column names
|
||||
public void displayColumnNames() throws com.sun.star.uno.Exception
|
||||
|
@ -95,16 +95,7 @@ public class PageHelper
|
||||
return xDrawPages.insertNewByIndex( nIndex );
|
||||
}
|
||||
|
||||
/** removes the given page
|
||||
*/
|
||||
static public void removeDrawPage( XComponent xComponent, XDrawPage xDrawPage )
|
||||
{
|
||||
XDrawPagesSupplier xDrawPagesSupplier =
|
||||
UnoRuntime.queryInterface(
|
||||
XDrawPagesSupplier.class, xComponent );
|
||||
XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
|
||||
xDrawPages.remove( xDrawPage );
|
||||
}
|
||||
|
||||
|
||||
/** get size of the given page
|
||||
*/
|
||||
@ -156,26 +147,9 @@ public class PageHelper
|
||||
return xDrawPages.insertNewByIndex( nIndex );
|
||||
}
|
||||
|
||||
/** removes the given page
|
||||
*/
|
||||
static public void removeMasterPage( XComponent xComponent, XDrawPage xDrawPage )
|
||||
{
|
||||
XMasterPagesSupplier xMasterPagesSupplier =
|
||||
UnoRuntime.queryInterface(
|
||||
XMasterPagesSupplier.class, xComponent );
|
||||
XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
|
||||
xDrawPages.remove( xDrawPage );
|
||||
}
|
||||
|
||||
/** return the corresponding masterpage for the giving drawpage
|
||||
*/
|
||||
static public XDrawPage getMasterPage( XDrawPage xDrawPage )
|
||||
{
|
||||
XMasterPageTarget xMasterPageTarget =
|
||||
UnoRuntime.queryInterface(
|
||||
XMasterPageTarget.class, xDrawPage );
|
||||
return xMasterPageTarget.getMasterPage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** sets given masterpage at the drawpage
|
||||
*/
|
||||
|
@ -76,11 +76,7 @@ public class DocumentHelper
|
||||
);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public static DocumentHelper blankTextDocument( XComponentContext xCtx ) throws com.sun.star.uno.Exception
|
||||
{
|
||||
return blankDocument( xCtx, DocumentType.WRITER );
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public static DocumentHelper blankDocument( XComponentContext xCtx, DocumentType eType ) throws com.sun.star.uno.Exception
|
||||
|
@ -26,25 +26,13 @@ public class DocumentType extends com.sun.star.uno.Enum
|
||||
super( value );
|
||||
}
|
||||
|
||||
public static DocumentType getDefault()
|
||||
{
|
||||
return WRITER;
|
||||
}
|
||||
|
||||
|
||||
public static final DocumentType WRITER = new DocumentType(0);
|
||||
public static final DocumentType CALC = new DocumentType(1);
|
||||
public static final DocumentType DRAWING = new DocumentType(2);
|
||||
public static final DocumentType UNKNOWN = new DocumentType(-1);
|
||||
|
||||
public static DocumentType fromInt(int value)
|
||||
{
|
||||
switch(value)
|
||||
{
|
||||
case 0: return WRITER;
|
||||
case 1: return CALC;
|
||||
case 2: return DRAWING;
|
||||
default: return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,15 +104,7 @@ class DocumentViewHelper
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves a dispatcher for the given URL, obtained at the current view of the document
|
||||
*/
|
||||
public XDispatch getDispatcher( String sURL ) throws java.lang.Exception
|
||||
{
|
||||
URL[] aURL = new URL[] { new URL() };
|
||||
aURL[0].Complete = sURL;
|
||||
return getDispatcher( aURL );
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* retrieves the form controller belonging to a given logical form
|
||||
|
@ -45,33 +45,9 @@ import com.sun.star.form.*;
|
||||
*/
|
||||
public class FLTools
|
||||
{
|
||||
/* ------------------------------------------------------------------ */
|
||||
static void dump_Object( Object aObject )
|
||||
{
|
||||
XServiceInfo xSI = UNO.queryServiceInfo( aObject );
|
||||
if ( null != xSI )
|
||||
System.out.println( "dumping object with name \"" + xSI.getImplementationName() + "\"" );
|
||||
else
|
||||
System.out.println( "object has no service info!" );
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** translates a string containing an URL into a complete
|
||||
<type scope="com.sun.star.util">URL</type> object.
|
||||
*/
|
||||
static public URL parseURL( String sURL, XComponentContext xCtx ) throws java.lang.Exception
|
||||
{
|
||||
URL[] aURL = new URL[] { new URL() };
|
||||
aURL[0].Complete = sURL;
|
||||
// need an URLTransformer
|
||||
XURLTransformer xTransformer = UnoRuntime.queryInterface(
|
||||
XURLTransformer.class,
|
||||
xCtx.getServiceManager().createInstanceWithContext(
|
||||
"com.sun.star.util.URLTransformer", xCtx ) );
|
||||
xTransformer.parseStrict( aURL );
|
||||
|
||||
return aURL[0];
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** returns the name of the given form component
|
||||
@ -122,39 +98,7 @@ public class FLTools
|
||||
return sLabel;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves the index of a form component within its parent
|
||||
*/
|
||||
static public int getIndexInParent( Object aContainer, Object aElement ) throws com.sun.star.uno.Exception
|
||||
{
|
||||
int nIndex = -1;
|
||||
|
||||
// norm the element
|
||||
XInterface xElement = UnoRuntime.queryInterface(
|
||||
XInterface.class, aElement );
|
||||
|
||||
// get the container
|
||||
XIndexContainer xIndexCont = UNO.queryIndexContainer( aContainer );
|
||||
if ( null != xIndexCont )
|
||||
{
|
||||
// loop through all children
|
||||
int nCount = xIndexCont.getCount();
|
||||
for ( int i = 0; i < nCount; ++i )
|
||||
{
|
||||
// compare with the element
|
||||
XInterface xCurrent = UnoRuntime.queryInterface(
|
||||
XInterface.class, xIndexCont.getByIndex( 0 ) );
|
||||
if ( xCurrent.equals( xElement ) )
|
||||
{ // found
|
||||
nIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// outta here
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves the parent of the given object
|
||||
|
@ -43,21 +43,9 @@ public class FormLayer
|
||||
m_insertPage = -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** sets the page which is to be used for subsequent insertions of controls/shapes
|
||||
*/
|
||||
void setInsertPage( int page )
|
||||
{
|
||||
m_insertPage = page;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** retrieves the page which is to be used for subsequent insertions of controls/shapes
|
||||
*/
|
||||
final int getInsertPage( )
|
||||
{
|
||||
return m_insertPage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/** creates a control in the document
|
||||
|
@ -106,25 +106,9 @@ public class HsqlDatabase
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
/** executes the given SQL statement via the defaultConnection
|
||||
*/
|
||||
public void executeSQL( String statementString ) throws SQLException
|
||||
{
|
||||
XStatement statement = defaultConnection().createStatement();
|
||||
statement.execute( statementString );
|
||||
}
|
||||
|
||||
/** stores the database document
|
||||
*/
|
||||
public void store() throws IOException
|
||||
{
|
||||
if ( m_databaseDocument != null )
|
||||
{
|
||||
XStorable storeDoc = UnoRuntime.queryInterface( XStorable.class,
|
||||
m_databaseDocument );
|
||||
storeDoc.store();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** closes the database document
|
||||
*
|
||||
@ -198,12 +182,7 @@ public class HsqlDatabase
|
||||
return m_databaseDocument.getDataSource();
|
||||
}
|
||||
|
||||
/** returns the model interface of the underlying database document
|
||||
*/
|
||||
XModel getModel()
|
||||
{
|
||||
return UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
|
||||
}
|
||||
|
||||
|
||||
/** returns the URL of the ODB document represented by this instance
|
||||
*/
|
||||
@ -212,12 +191,7 @@ public class HsqlDatabase
|
||||
return m_databaseDocumentFile;
|
||||
}
|
||||
|
||||
/** creates a row set operating the database, with a given command/type
|
||||
*/
|
||||
public RowSet createRowSet( int _commandType, String _command )
|
||||
{
|
||||
return new RowSet( m_context, getDocumentURL(), _commandType, _command );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
|
@ -52,12 +52,7 @@ class InteractionRequest implements XInteractionRequest
|
||||
m_aContinuations = new ArrayList<XInteractionContinuation>();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public void addContinuation( XInteractionContinuation xCont )
|
||||
{
|
||||
if ( null != xCont )
|
||||
m_aContinuations.add( xCont );
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
public Object getRequest( )
|
||||
|
@ -36,28 +36,5 @@ public class SpreadsheetView extends DocumentViewHelper
|
||||
super( orb, document, controller );
|
||||
}
|
||||
|
||||
/** activates the sheet with the given index
|
||||
*/
|
||||
void activateSheet( int sheetIndex )
|
||||
{
|
||||
try
|
||||
{
|
||||
// get the sheet to activate
|
||||
XSpreadsheetDocument doc = UnoRuntime.queryInterface(
|
||||
XSpreadsheetDocument.class, getDocument().getDocument() );
|
||||
XIndexAccess sheets = UnoRuntime.queryInterface(
|
||||
XIndexAccess.class, doc.getSheets() );
|
||||
|
||||
XSpreadsheet sheet = UnoRuntime.queryInterface(
|
||||
XSpreadsheet.class, sheets.getByIndex( sheetIndex ) );
|
||||
|
||||
// activate
|
||||
XSpreadsheetView view = UnoRuntime.queryInterface(
|
||||
XSpreadsheetView.class, getController() );
|
||||
view.setActiveSheet( sheet );
|
||||
}
|
||||
catch( com.sun.star.uno.Exception e )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,7 @@ public class UNO
|
||||
return UnoRuntime.queryInterface( XComponent.class, aObject );
|
||||
}
|
||||
|
||||
public static XTablesSupplier queryTablesSupplier( Object aObject )
|
||||
{
|
||||
return UnoRuntime.queryInterface( XTablesSupplier.class, aObject );
|
||||
}
|
||||
|
||||
|
||||
/* replace Foo with the identifier of your choice.
|
||||
|
||||
|
@ -205,37 +205,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param _sRegistryPath the path a registryNode
|
||||
* @param _sImageName the name of the image
|
||||
*/
|
||||
public String getImageUrl(String _sRegistryPath, String _sImageName) {
|
||||
String sImageUrl = "";
|
||||
try {
|
||||
// retrieve the configuration node of the extension
|
||||
XNameAccess xNameAccess = getRegistryKeyContent(_sRegistryPath);
|
||||
if (xNameAccess != null){
|
||||
if (xNameAccess.hasByName(_sImageName)){
|
||||
// get the Image Url and process the Url by the macroexpander...
|
||||
sImageUrl = (String) xNameAccess.getByName(_sImageName);
|
||||
Object oMacroExpander = this.m_xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
|
||||
XMacroExpander xMacroExpander = UnoRuntime.queryInterface(XMacroExpander.class, oMacroExpander);
|
||||
sImageUrl = xMacroExpander.expandMacros(sImageUrl);
|
||||
sImageUrl = sImageUrl.substring(new String("vnd.sun.star.expand:").length(), sImageUrl.length());
|
||||
sImageUrl = sImageUrl.trim();
|
||||
sImageUrl += "/" + _sImageName;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
/* perform individual exception handling here.
|
||||
* Possible exception types are:
|
||||
* com.sun.star.lang.IllegalArgumentException,
|
||||
* com.sun.star.lang.WrappedTargetException,
|
||||
*/
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
return sImageUrl;
|
||||
}
|
||||
|
||||
|
||||
protected void createDialog(XMultiComponentFactory _xMCF) {
|
||||
try {
|
||||
@ -266,16 +236,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
|
||||
|
||||
|
||||
public short executeDialogWithembeddedExampleSnippets() {
|
||||
if (m_xWindowPeer == null){
|
||||
createWindowPeer();
|
||||
}
|
||||
addRoadmap();
|
||||
insertRoadmapItem(0, true, "Introduction", 1);
|
||||
insertRoadmapItem(1, true, "Documents", 2);
|
||||
xDialog = UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
|
||||
return xDialog.execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public short executeDialog() {
|
||||
@ -329,17 +290,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
}
|
||||
|
||||
|
||||
public void calculateDialogPosition(XWindow _xWindow) {
|
||||
Rectangle aFramePosSize = m_xModel.getCurrentController().getFrame().getComponentWindow().getPosSize();
|
||||
Rectangle CurPosSize = _xWindow.getPosSize();
|
||||
int WindowHeight = aFramePosSize.Height;
|
||||
int WindowWidth = aFramePosSize.Width;
|
||||
int DialogWidth = CurPosSize.Width;
|
||||
int DialogHeight = CurPosSize.Height;
|
||||
int iXPos = ((WindowWidth / 2) - (DialogWidth / 2));
|
||||
int iYPos = ((WindowHeight / 2) - (DialogHeight / 2));
|
||||
_xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -352,23 +303,10 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
return createWindowPeer(null);
|
||||
}
|
||||
|
||||
public void endExecute() {
|
||||
xDialog.endExecute();
|
||||
}
|
||||
|
||||
|
||||
public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) {
|
||||
try {
|
||||
Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName);
|
||||
XMultiPropertySet xControlMultiPropertySet = UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel);
|
||||
xControlMultiPropertySet.setPropertyValues(sProperties, sValues);
|
||||
m_xDlgModelNameContainer.insertByName(sName, oControlModel);
|
||||
return oControlModel;
|
||||
} catch (com.sun.star.uno.Exception exception) {
|
||||
exception.printStackTrace(System.err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private XFixedText insertFixedText(XMouseListener _xMouseListener, int _nPosX, int _nPosY, int _nWidth, int _nStep, String _sLabel){
|
||||
@ -1094,9 +1032,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
return xFFModelPSet;
|
||||
}
|
||||
|
||||
public void convertUnits(){
|
||||
// iXPixelFactor = (int) (100000/xDevice.getInfo().PixelPerMeterX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private XTextComponent insertFileControl(XTextListener _xTextListener, int _nPosX, int _nPosY, int _nWidth){
|
||||
@ -1184,17 +1120,7 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
|
||||
return xButton;
|
||||
}
|
||||
|
||||
/** gets the WindowPeer of a frame
|
||||
* @param _xTextDocument the instance of a textdocument
|
||||
* @return the windowpeer of the frame
|
||||
*/
|
||||
public XWindowPeer getWindowPeer(XTextDocument _xTextDocument){
|
||||
XModel xModel = UnoRuntime.queryInterface(XModel.class, _xTextDocument);
|
||||
XFrame xFrame = xModel.getCurrentController().getFrame();
|
||||
XWindow xWindow = xFrame.getContainerWindow();
|
||||
XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xWindow);
|
||||
return xWindowPeer;
|
||||
}
|
||||
|
||||
|
||||
public XFrame getCurrentFrame(){
|
||||
XFrame xRetFrame = null;
|
||||
|
@ -152,10 +152,7 @@ public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
|
||||
return xTopWindow;
|
||||
}
|
||||
|
||||
public void addMenuBar(XWindow _xWindow){
|
||||
XTopWindow xTopWindow = UnoRuntime.queryInterface(XTopWindow.class, _xWindow);
|
||||
addMenuBar(xTopWindow, this);
|
||||
}
|
||||
|
||||
|
||||
public void itemSelected(MenuEvent menuEvent){
|
||||
// find out which menu item has been triggered,
|
||||
|
@ -490,50 +490,7 @@ public class FunctionHelper
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Dispatch an URL to given frame.
|
||||
* Caller can register himself for following result events for dispatched
|
||||
* URL too. Notifications are guaranteed (instead of dispatch())
|
||||
* Returning of the dispatch object isn't necessary.
|
||||
* Nobody must hold it alive longer the dispatch needs.
|
||||
*
|
||||
* @param xFrame frame which should be the target of this dispatch
|
||||
* @param aURL full parsed and converted office URL for dispatch
|
||||
* @param lProperties optional arguments for dispatch
|
||||
* @param xListener optional listener which is registered automatically for status events
|
||||
* (Note: Deregistration is not supported. Dispatcher does it automatically.)
|
||||
*/
|
||||
public static void executeWithNotification(com.sun.star.frame.XFrame xFrame ,
|
||||
com.sun.star.util.URL aURL ,
|
||||
com.sun.star.beans.PropertyValue[] lProperties,
|
||||
com.sun.star.frame.XDispatchResultListener xListener )
|
||||
{
|
||||
try
|
||||
{
|
||||
// Query the frame for right interface which provides access to all available dispatch objects.
|
||||
com.sun.star.frame.XDispatchProvider xProvider = UnoRuntime.queryInterface(
|
||||
com.sun.star.frame.XDispatchProvider.class,
|
||||
xFrame);
|
||||
|
||||
// Ask himn for right dispatch object for given URL.
|
||||
// Force THIS frame as target for following dispatch.
|
||||
// Attention: The interface XNotifyingDispatch is an optional one!
|
||||
com.sun.star.frame.XDispatch xDispatcher = xProvider.queryDispatch(aURL,"",0);
|
||||
com.sun.star.frame.XNotifyingDispatch xNotifyingDispatcher = UnoRuntime.queryInterface(
|
||||
com.sun.star.frame.XNotifyingDispatch.class,
|
||||
xDispatcher);
|
||||
|
||||
// Dispatch the URL.
|
||||
if(xNotifyingDispatcher!=null)
|
||||
xNotifyingDispatcher.dispatchWithNotification(aURL,lProperties,xListener);
|
||||
}
|
||||
catch(com.sun.star.uno.RuntimeException exUno)
|
||||
{
|
||||
// Any UNO method of this scope can throw this exception.
|
||||
// But there is nothing we can do then.
|
||||
exUno.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -782,78 +739,7 @@ public class FunctionHelper
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Try to close the document without any saving of modifications.
|
||||
* We can try it only! Controller and/or model of this document
|
||||
* can disagree with that. But mostly they doesn't do so.
|
||||
*
|
||||
* @param xDocument document which should be clcosed
|
||||
*/
|
||||
public static void closeDocument(com.sun.star.lang.XComponent xDocument)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check supported functionality of the document (model or controller).
|
||||
com.sun.star.frame.XModel xModel =
|
||||
UnoRuntime.queryInterface(
|
||||
com.sun.star.frame.XModel.class, xDocument);
|
||||
|
||||
if(xModel!=null)
|
||||
{
|
||||
// It's a full featured office document.
|
||||
// Reset the modify state of it and close it.
|
||||
// Note: Model can disgree by throwing a veto exception.
|
||||
com.sun.star.util.XModifiable xModify =
|
||||
UnoRuntime.queryInterface(
|
||||
com.sun.star.util.XModifiable.class, xModel);
|
||||
|
||||
xModify.setModified(false);
|
||||
xDocument.dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's a document which supports a controller .. or may by a pure
|
||||
// window only. If it's at least a controller - we can try to
|
||||
// suspend him. But - he can disagree with that!
|
||||
com.sun.star.frame.XController xController =
|
||||
UnoRuntime.queryInterface(
|
||||
com.sun.star.frame.XController.class, xDocument);
|
||||
|
||||
if(xController!=null)
|
||||
{
|
||||
if(xController.suspend(true)==true)
|
||||
{
|
||||
// Note: Don't dispose the controller - destroy the frame
|
||||
// to make it right!
|
||||
com.sun.star.frame.XFrame xFrame = xController.getFrame();
|
||||
xFrame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(com.sun.star.beans.PropertyVetoException exVeto)
|
||||
{
|
||||
// Can be thrown by "setModified()" call on model.
|
||||
// He disagree with our request.
|
||||
// But there is nothing to do then. Following "dispose()" call wasn't
|
||||
// never called (because we catch it before). Closing failed -that's it.
|
||||
exVeto.printStackTrace();
|
||||
}
|
||||
catch(com.sun.star.lang.DisposedException exDisposed)
|
||||
{
|
||||
// If an UNO object was already disposed before - he throw this special
|
||||
// runtime exception. Of course every UNO call must be look for that -
|
||||
// but it's a question of error handling.
|
||||
// For demonstration this exception is handled here.
|
||||
exDisposed.printStackTrace();
|
||||
}
|
||||
catch(com.sun.star.uno.RuntimeException exRuntime)
|
||||
{
|
||||
// Every uno call can throw that.
|
||||
// Do nothing - closing failed - that's it.
|
||||
exRuntime.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -67,18 +67,7 @@ public class OfficeConnect
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* close connection to remote office if it exist
|
||||
*/
|
||||
public static synchronized void disconnect()
|
||||
{
|
||||
if(maConnection!=null)
|
||||
{
|
||||
mxServiceManager=null;
|
||||
mxOfficeContext=null;
|
||||
maConnection=null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -112,71 +101,9 @@ public class OfficeConnect
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* create uno components inside remote office process
|
||||
* After connection of these process to a running office we have access to
|
||||
* remote service manager of it.
|
||||
* So we can use it to create all existing services. Use this method to create
|
||||
* components by name and get her interface. Casting of it to right target
|
||||
* interface is part of your implementation.
|
||||
*
|
||||
* @param aType describe class type of created service
|
||||
* Returned object can be casted directly to this one.
|
||||
* Uno query was done by this method automatically.
|
||||
* @param sServiceSpecifier name of service which should be created
|
||||
* @return the new created service object
|
||||
*/
|
||||
public static synchronized <T> T createRemoteInstance(
|
||||
Class<T> aType, String sServiceSpecifier)
|
||||
{
|
||||
T aResult = null;
|
||||
try
|
||||
{
|
||||
aResult = UnoRuntime.queryInterface(aType,
|
||||
mxServiceManager.createInstanceWithContext(
|
||||
sServiceSpecifier, mxOfficeContext));
|
||||
}
|
||||
catch (com.sun.star.uno.Exception ex)
|
||||
{
|
||||
System.err.println("Couldn't create Service of type "
|
||||
+ sServiceSpecifier + ": " + ex);
|
||||
System.exit(0);
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* same as "createRemoteInstance()" but supports additional parameter for
|
||||
* initializing created object
|
||||
*
|
||||
* @param lArguments optional arguments
|
||||
* They are used to initialize new created service.
|
||||
* @param aType Description of Parameter
|
||||
* @param sServiceSpecifier Description of Parameter
|
||||
* @return the new create service object
|
||||
*/
|
||||
public static synchronized <T> T createRemoteInstanceWithArguments(
|
||||
Class<T> aType, String sServiceSpecifier, Any[] lArguments)
|
||||
{
|
||||
T aResult = null;
|
||||
try
|
||||
{
|
||||
aResult = UnoRuntime.queryInterface(aType,
|
||||
mxServiceManager.createInstanceWithArgumentsAndContext(
|
||||
sServiceSpecifier, lArguments, mxOfficeContext));
|
||||
}
|
||||
catch (com.sun.star.uno.Exception ex)
|
||||
{
|
||||
System.err.println("Couldn't create Service of type "
|
||||
+ sServiceSpecifier + ": " + ex);
|
||||
System.exit(0);
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* returns remote component context of the connected office
|
||||
|
@ -72,10 +72,7 @@ public class PropChgHelper implements
|
||||
return xPropSet;
|
||||
}
|
||||
|
||||
public String[] GetPropNames()
|
||||
{
|
||||
return aPropNames;
|
||||
}
|
||||
|
||||
|
||||
public void LaunchEvent( LinguServiceEvent aEvt )
|
||||
{
|
||||
|
@ -71,10 +71,7 @@ public class OfficeConnect
|
||||
|
||||
|
||||
|
||||
public static synchronized OfficeConnect getConnection()
|
||||
{
|
||||
return maConnection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -127,32 +124,7 @@ public class OfficeConnect
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* same as "createRemoteInstance()" but supports additional parameter for initializing created object
|
||||
*
|
||||
* @param lArguments optional arguments
|
||||
* They are used to initialize new created service.
|
||||
* @param aType Description of Parameter
|
||||
* @param sServiceSpecifier Description of Parameter
|
||||
* @return Description of the Returned Value
|
||||
*/
|
||||
public <T> T createRemoteInstanceWithArguments(Class<T> aType, String sServiceSpecifier, Any[] lArguments)
|
||||
{
|
||||
T aResult = null;
|
||||
try
|
||||
{
|
||||
aResult = UnoRuntime.queryInterface(
|
||||
aType, mxServiceManager.createInstanceWithArgumentsAndContext(
|
||||
sServiceSpecifier, lArguments, mxOfficeContext));
|
||||
}
|
||||
catch (com.sun.star.uno.Exception ex)
|
||||
{
|
||||
System.err.println("Couldn't create Service of type " + sServiceSpecifier + ": " + ex);
|
||||
ex.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -274,25 +274,9 @@ class ScriptSelectorPanel extends JPanel {
|
||||
add(textField, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public void removeNode(DefaultMutableTreeNode node) {
|
||||
MutableTreeNode parent = (MutableTreeNode)(node.getParent());
|
||||
if (parent != null) {
|
||||
treeModel.removeNodeFromParent(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void addNode(DefaultMutableTreeNode parent, XBrowseNode xbn) {
|
||||
DefaultMutableTreeNode newNode =
|
||||
new DefaultMutableTreeNode(xbn) {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ((XBrowseNode)getUserObject()).getName();
|
||||
}
|
||||
};
|
||||
|
||||
treeModel.insertNodeInto(newNode, parent, parent.getChildCount());
|
||||
tree.scrollPathToVisible(new TreePath(newNode.getPath()));
|
||||
}
|
||||
|
||||
|
||||
private void initNodes(XBrowseNode parent, DefaultMutableTreeNode top) {
|
||||
if ( parent == null || parent.hasChildNodes() == false )
|
||||
|
@ -163,30 +163,9 @@ public class ExampleAddIn
|
||||
|
||||
// XExampleAddIn
|
||||
|
||||
public int getIncremented( int nValue )
|
||||
{
|
||||
return nValue + 1;
|
||||
}
|
||||
|
||||
public com.sun.star.sheet.XVolatileResult getCounter(String aName)
|
||||
{
|
||||
if ( aResults == null )
|
||||
{
|
||||
// create the table of results, and start a thread to increment
|
||||
// all counters
|
||||
aResults = new java.util.HashMap<String, ExampleAddInResult>();
|
||||
ExampleAddInThread aThread = new ExampleAddInThread( aResults );
|
||||
aThread.start();
|
||||
}
|
||||
|
||||
ExampleAddInResult aResult = aResults.get(aName);
|
||||
if ( aResult == null )
|
||||
{
|
||||
aResult = new ExampleAddInResult(aName);
|
||||
aResults.put( aName, aResult );
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
// XAddIn
|
||||
|
||||
|
@ -84,9 +84,7 @@ public class HideableTreeModel implements TreeModel {
|
||||
}
|
||||
|
||||
|
||||
public void reload() {
|
||||
reload(getRoot());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void reload(Object node) {
|
||||
@ -101,9 +99,7 @@ public class HideableTreeModel implements TreeModel {
|
||||
nodeChanged(path.getLastPathComponent());
|
||||
}
|
||||
|
||||
public void nodeInserted(Object node, Object child) {
|
||||
nodeInserted(node, child, -1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void nodeInserted(Object node, Object child, int index) {
|
||||
@ -164,11 +160,7 @@ public class HideableTreeModel implements TreeModel {
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<TreePath> getExpandedPaths(JTree tree) {
|
||||
ArrayList<TreePath> expandedPaths = new ArrayList<TreePath>();
|
||||
addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths);
|
||||
return expandedPaths;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addExpandedPaths(JTree tree, TreePath path, ArrayList<TreePath> pathlist) {
|
||||
@ -181,11 +173,7 @@ public class HideableTreeModel implements TreeModel {
|
||||
}
|
||||
|
||||
|
||||
public void expandPaths(JTree tree, ArrayList<TreePath> pathlist) {
|
||||
for(int i = 0; i < pathlist.size(); i++) {
|
||||
tree.expandPath(pathlist.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isLeaf(Object _oNode) {
|
||||
@ -241,23 +229,10 @@ public class HideableTreeModel implements TreeModel {
|
||||
}
|
||||
|
||||
|
||||
public boolean isPathToNodeVisible(Object node) {
|
||||
Object[] path = getPathToRoot(node);
|
||||
for(int i = 0; i < path.length; i++) {
|
||||
if(!isNodeVisible(path[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void ensurePathToNodeVisible(Object node) {
|
||||
Object[] path = getPathToRoot(node);
|
||||
for(int i = 0; i < path.length; i++) {
|
||||
setNodeVisible(path[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Object getChild(Object parent, int index) {
|
||||
|
@ -441,17 +441,6 @@ public class Inspector{
|
||||
return xFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the service information into the given registry key.
|
||||
* This method is called by the <code>JavaLoader</code>
|
||||
* <p>
|
||||
* @return returns true if the operation succeeded
|
||||
* @param regKey the registryKey
|
||||
* @see com.sun.star.comp.loader.JavaLoader
|
||||
*/
|
||||
public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
|
||||
return (Factory.writeRegistryServiceInfo(_Inspector.class.getName(), _Inspector.getServiceNames(), regKey)
|
||||
&& InspectorAddon.__writeRegistryServiceInfo(regKey));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -201,15 +201,7 @@ public class Introspector extends WeakBase{
|
||||
}}
|
||||
|
||||
|
||||
protected XIdlField[] getFieldsOfType(Type _aType){
|
||||
try{
|
||||
XIdlClass xIdlClass = mxIdlReflection.forName(_aType.getTypeName());
|
||||
return xIdlClass.getFields();
|
||||
}
|
||||
catch( Exception e ) {
|
||||
System.err.println( e );
|
||||
return null;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
public boolean hasMethods(Object _oUnoObject){
|
||||
@ -552,12 +544,7 @@ public class Introspector extends WeakBase{
|
||||
}
|
||||
|
||||
|
||||
public static boolean isValid(Object _oObject){
|
||||
if (_oObject != null){
|
||||
return (!AnyConverter.isVoid(_oObject));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isArray(Object _oObject){
|
||||
|
@ -659,13 +659,7 @@ private class UnoObjectDefinition{
|
||||
}
|
||||
|
||||
|
||||
public boolean hasParameterObjects(){
|
||||
boolean breturn = false;
|
||||
if (m_oParameterObjects != null){
|
||||
breturn = m_oParameterObjects.length > 0;
|
||||
}
|
||||
return breturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getVariableStemName(TypeClass _aTypeClass){
|
||||
|
@ -324,9 +324,7 @@ public class UnoNode{
|
||||
}
|
||||
|
||||
|
||||
public static String getNodeDescription(Object _oUnoObject, int _nIndex){
|
||||
return getNodeDescription(_oUnoObject) + "[" + (_nIndex + 1) + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getNodeDescription(Object _oUnoObject){
|
||||
|
@ -56,7 +56,7 @@ public interface XDialogProvider {
|
||||
|
||||
public void selectSourceCodeLanguage(int _nLanguage);
|
||||
|
||||
public void paint();
|
||||
|
||||
|
||||
// returns one of the constants defined in XLanguageSourceCodeGenerator
|
||||
public int getLanguage();
|
||||
|
@ -67,7 +67,7 @@ public interface XLanguageSourceCodeGenerator {
|
||||
|
||||
public String getshortTypeDescription();
|
||||
|
||||
public String getunsignedshortTypeDescription();
|
||||
|
||||
|
||||
public String getlongTypeDescription();
|
||||
|
||||
@ -85,11 +85,11 @@ public interface XLanguageSourceCodeGenerator {
|
||||
|
||||
public String getstringTypeDescription(boolean _bAsHeaderSourceCode);
|
||||
|
||||
public String gettypeTypeDescription(boolean _bAsHeaderSourceCode);
|
||||
|
||||
|
||||
public String getanyTypeDescription(boolean _bAsHeaderSourceCode);
|
||||
|
||||
public String getArrayDeclaration(String sVariableDeclaration);
|
||||
|
||||
|
||||
public String getVariableDeclaration(String _sTypeString, String _sVariableName, boolean _bIsArray, TypeClass aTypeClass, boolean _bInitialize);
|
||||
|
||||
|
@ -26,5 +26,5 @@ public interface XTreePathProvider {
|
||||
|
||||
public XTreePathProvider getParentPath();
|
||||
|
||||
public XTreePathProvider pathByAddingChild(XUnoNode _oUnoNode);
|
||||
|
||||
}
|
||||
|
@ -90,23 +90,9 @@ public class CalcAddins {
|
||||
private static final short shortGETMYSECONDVALUE = 1;
|
||||
|
||||
|
||||
/** TO DO:
|
||||
* This is where you implement all methods of your interface. The parameters have to
|
||||
* be the same as in your IDL file and their types have to be the correct
|
||||
* IDL-to-Java mappings of their types in the IDL file.
|
||||
*/
|
||||
public int getMyFirstValue(
|
||||
com.sun.star.beans.XPropertySet xOptions
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getMySecondValue(
|
||||
com.sun.star.beans.XPropertySet xOptions,
|
||||
int intDummy
|
||||
) {
|
||||
return( 2 + intDummy );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Implement method from interface XServiceName
|
||||
|
@ -55,109 +55,27 @@ public class Assurance
|
||||
assure(msg, s, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two boolean values are equal
|
||||
* @param expected specifies the expected boolean value
|
||||
* @param actual specifies the actual boolean value
|
||||
*/
|
||||
protected void assureEquals( boolean expected, boolean actual ) {
|
||||
assureEquals( "Equality test failed", expected, new Boolean( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two boolean values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected boolean value
|
||||
* @param actual specifies the actual boolean value
|
||||
*/
|
||||
protected void assureEquals( String message, boolean expected, boolean actual ) {
|
||||
assureEquals( message, expected, actual, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two byte values are equal
|
||||
* @param expected specifies the expected byte value
|
||||
* @param actual specifies the actual byte value
|
||||
*/
|
||||
protected void assureEquals( byte expected, byte actual ) {
|
||||
assureEquals( "Equality test failed", new Byte( expected ), new Byte( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two byte values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected byte value
|
||||
* @param actual specifies the actual byte value
|
||||
*/
|
||||
protected void assureEquals( String message, byte expected, byte actual ) {
|
||||
assureEquals( message, new Byte( expected ), new Byte( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two double values are equal
|
||||
* @param expected specifies the expected double value
|
||||
* @param actual specifies the actual double value
|
||||
*/
|
||||
protected void assureEquals( double expected, double actual ) {
|
||||
assureEquals( "Equality test failed", new Double( expected ), new Double( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two double values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected double value
|
||||
* @param actual specifies the actual double value
|
||||
*/
|
||||
protected void assureEquals( String message, double expected, double actual ) {
|
||||
assureEquals( message, new Double( expected ), new Double( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two float values are equal
|
||||
* @param expected specifies the expected float value
|
||||
* @param actual specifies the actual float value
|
||||
*/
|
||||
protected void assureEquals( float expected, float actual ) {
|
||||
assureEquals( "Equality test failed", new Float( expected ), new Float( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two float values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected float value
|
||||
* @param actual specifies the actual float value
|
||||
*/
|
||||
protected void assureEquals( String message, float expected, float actual ) {
|
||||
assureEquals( message, new Float( expected ), new Float( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two short values are equal
|
||||
* @param expected specifies the expected short value
|
||||
* @param actual specifies the actual short value
|
||||
*/
|
||||
protected void assureEquals( short expected, short actual ) {
|
||||
assureEquals( "Equality test failed", new Short( expected ), new Short( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two short values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected short value
|
||||
* @param actual specifies the actual short value
|
||||
*/
|
||||
protected void assureEquals( String message, short expected, short actual ) {
|
||||
assureEquals( message, new Short( expected ), new Short( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two int values are equal
|
||||
* @param expected specifies the expected int value
|
||||
* @param actual specifies the actual int value
|
||||
*/
|
||||
protected void assureEquals( int expected, int actual ) {
|
||||
assureEquals( "Equality test failed", new Integer( expected ), new Integer( actual ), false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Assure that two int values are equal
|
||||
@ -169,33 +87,11 @@ public class Assurance
|
||||
assureEquals( message, new Integer( expected ), new Integer( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two long values are equal
|
||||
* @param expected specifies the expected long value
|
||||
* @param actual specifies the actual long value
|
||||
*/
|
||||
protected void assureEquals( long expected, long actual ) {
|
||||
assureEquals( "Equality test failed", new Long( expected ), new Long( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two long values are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected long value
|
||||
* @param actual specifies the actual long value
|
||||
*/
|
||||
protected void assureEquals( String message, long expected, long actual ) {
|
||||
assureEquals( message, new Long( expected ), new Long( actual ), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two string values are equal
|
||||
* @param expected specifies the expected string value
|
||||
* @param actual specifies the actual string value
|
||||
*/
|
||||
protected void assureEquals( String expected, String actual ) {
|
||||
assureEquals( "Equality test failed", expected, actual, false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Assure that two string values are equal
|
||||
@ -207,24 +103,9 @@ public class Assurance
|
||||
assureEquals( message, expected, actual, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two object are equal
|
||||
* @param expected specifies the expected object value
|
||||
* @param actual specifies the actual object value
|
||||
*/
|
||||
protected void assureEquals( Object expected, Object actual ) {
|
||||
assureEquals( "Equality test failed", expected, actual, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Assure that two objects are equal
|
||||
* @param message the message to print when the equality test fails
|
||||
* @param expected specifies the expected object value
|
||||
* @param actual specifies the actual object value
|
||||
*/
|
||||
protected void assureEquals( String message, Object expected, Object actual ) {
|
||||
assureEquals( message, expected, actual, false );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* assures the two given sequences are of equal length, and have equal content
|
||||
@ -239,13 +120,7 @@ public class Assurance
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* assures the two given sequences are of equal length, and have equal content
|
||||
*/
|
||||
public <T> void assureEquals( String i_message, T[] i_expected, T[] i_actual )
|
||||
{
|
||||
assureEquals( i_message, i_expected, i_actual, false );
|
||||
}
|
||||
|
||||
|
||||
/** invokes a given method on a given object, and assures a certain exception is caught
|
||||
* @param _message is the message to print when the check fails
|
||||
@ -301,49 +176,11 @@ public class Assurance
|
||||
assureException( _message, _object, _methodName, argClasses, _methodArgs, _expectedExceptionClass );
|
||||
}
|
||||
|
||||
/** invokes a given method on a given object, and assures a certain exception is caught
|
||||
* @param _object is the object to invoke the method on
|
||||
* @param _methodName is the name of the method to invoke
|
||||
* @param _methodArgs are the arguments to pass to the method. Those implicitly define
|
||||
* the classes of the arguments of the method which is called.
|
||||
* @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
|
||||
* it means that <em>no</em> exception must be throw by invoking the method.
|
||||
*/
|
||||
protected void assureException( final Object _object, final String _methodName, final Object[] _methodArgs,
|
||||
final Class<?> _expectedExceptionClass )
|
||||
{
|
||||
assureException(
|
||||
"did not catch the expected exception (" +
|
||||
( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) +
|
||||
") while calling " + _object.getClass().getName() + "." + _methodName,
|
||||
_object, _methodName, _methodArgs, _expectedExceptionClass );
|
||||
}
|
||||
|
||||
/** invokes a given method on a given object, and assures a certain exception is caught
|
||||
* @param _object is the object to invoke the method on
|
||||
* @param _methodName is the name of the method to invoke
|
||||
* @param _methodArgs are the arguments to pass to the method
|
||||
* @param _argClasses are the classes to assume for the arguments of the methods
|
||||
* @param _expectedExceptionClass is the class of the exception to be caught. If this is null,
|
||||
* it means that <em>no</em> exception must be throw by invoking the method.
|
||||
*/
|
||||
protected void assureException( final Object _object, final String _methodName, final Class<?>[] _argClasses,
|
||||
final Object[] _methodArgs, final Class<?> _expectedExceptionClass )
|
||||
{
|
||||
assureException(
|
||||
"did not catch the expected exception (" +
|
||||
( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) +
|
||||
") while calling " + _object.getClass().getName() + "." + _methodName,
|
||||
_object, _methodName, _argClasses, _methodArgs, _expectedExceptionClass );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the currently executed method as failed.
|
||||
* This function generates "Test did fail." as standard message.
|
||||
*/
|
||||
protected void failed() {
|
||||
assure("Test did fail.", false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Mark the currently executed method as failed.
|
||||
|
@ -188,44 +188,7 @@ public class DBHelper
|
||||
aSQLThread.start();
|
||||
}
|
||||
|
||||
public int QueryIntFromSQL(Connection _aCon, String _sSQL, String _sColumnName)
|
||||
throws ValueNotFoundException
|
||||
{
|
||||
Statement oStmt = null;
|
||||
int nValue = 0;
|
||||
try
|
||||
{
|
||||
oStmt = _aCon.createStatement();
|
||||
|
||||
ResultSet oResult = oStmt.executeQuery(_sSQL);
|
||||
oResult.next();
|
||||
|
||||
try
|
||||
{
|
||||
if (_sColumnName.length() == 0)
|
||||
{
|
||||
// take the first row value (started with 1)
|
||||
nValue = oResult.getInt(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
nValue = oResult.getInt(_sColumnName);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
String sError = e.getMessage();
|
||||
GlobalLogWriter.get().println("DB: Original SQL error: " + sError);
|
||||
throw new ValueNotFoundException("Can't execute SQL: " + _sSQL);
|
||||
}
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
String sError = e.getMessage();
|
||||
GlobalLogWriter.get().println("DB: Couldn't execute sql string " + _sSQL + "\n" + sError);
|
||||
}
|
||||
return nValue;
|
||||
}
|
||||
|
||||
public String Quote(String _sToQuote)
|
||||
{
|
||||
|
@ -71,13 +71,7 @@ public class DirectoryHelper
|
||||
return a.m_aFileList.toArray();
|
||||
}
|
||||
|
||||
public static Object[] traverse( String _sDirectory, boolean _bRecursiveIsAllowed )
|
||||
{
|
||||
DirectoryHelper a = new DirectoryHelper();
|
||||
a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
|
||||
a.traverse_impl(_sDirectory, null);
|
||||
return a.m_aFileList.toArray();
|
||||
}
|
||||
|
||||
|
||||
private void traverse_impl( String afileDirectory, FileFilter _aFileFilter )
|
||||
{
|
||||
|
@ -39,12 +39,7 @@ public class FileHelper
|
||||
|
||||
}
|
||||
|
||||
public static void MessageBox(String _sStr)
|
||||
{
|
||||
String sVersion = System.getProperty("java.version");
|
||||
String sOSName = System.getProperty("os.name");
|
||||
JOptionPane.showMessageDialog( null, _sStr, sVersion + " " + sOSName + " Hello World Debugger", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
|
||||
|
||||
public static boolean exists(String _sFile)
|
||||
{
|
||||
|
@ -175,13 +175,7 @@ abstract class FilenameHelper_impl implements Filenamer
|
||||
return FileHelper.isDir(getSystemPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true, if the file really exist.
|
||||
*/
|
||||
public boolean exists()
|
||||
{
|
||||
return FileHelper.exists(createAbsoluteFilename());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the current suffix
|
||||
|
@ -191,16 +191,7 @@ public class GraphicalDifferenceCheck
|
||||
return bOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for the comparance of graphical differences.
|
||||
* Method compares one document (_sInputFile) with an older document of the same name in the provided directory (_sReferencePath).
|
||||
*
|
||||
* The path _sOutputPath must be writeable
|
||||
*/
|
||||
public static boolean checkOneFile(String _sInputFile, String _sOutputPath, String _sReferencePath, GraphicalTestArguments _aGTA) throws ConvWatchException
|
||||
{
|
||||
return checkOneFile( _sInputFile, _sOutputPath, _sReferencePath, null, _aGTA);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -206,168 +206,13 @@ public class HTMLOutputter
|
||||
private final static String DIFFER_BM_TABLETITLE = "Diff file (RB)";
|
||||
|
||||
private final static String OK_TABLETITLE = "OK?";
|
||||
public void checkSection(String _sDocumentName)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
|
||||
|
||||
m_aOut.write( "<p>Legend:<br>");
|
||||
m_aOut.write( stronghtml(FIRSTGFX_TABLETITLE) + " contains the output printed via 'ghostscript' as a jpeg picture.<br>");
|
||||
m_aOut.write( stronghtml(SECONDGFX_TABLETITLE) + " contains the same document opened within OpenOffice.org also printed via ghostscript as jpeg.<br>");
|
||||
m_aOut.write( stronghtml(DIFFER_TABLETITLE)+" is build via composite from original and new picture. The result should be a whole black picture, if there are no differences.<br>At the moment "+stronghtml(STATUS_TABLETITLE)+" is only ok, if the difference file contains only one color (black).</p>" );
|
||||
m_aOut.write( stronghtml(DIFFER_BM_TABLETITLE) + " is build via composite from original and new picture after the border of both pictures are removed, so differences based on center problems may solved here");
|
||||
m_aOut.write( "</p>");
|
||||
m_aOut.write( "<p>Some words about the percentage value<br>");
|
||||
m_aOut.write( "If a character is on the original page (a) and on the new page this character is moved to an other position only (b) , this means the difference is 100%.<br>");
|
||||
m_aOut.write( "If character (b) is also bigger than character (a) the percentage is grow over the 100% mark.<br>");
|
||||
m_aOut.write( "This tool count only the pixels which are differ to it's background color. It makes no sense to count all pixels, or the difference percentage will most the time in a very low percentage range.");
|
||||
m_aOut.write( "</p>");
|
||||
|
||||
m_aOut.write( "<table class=\"infotable\">" + ls);
|
||||
|
||||
m_aOut.write( "<TR>" + ls);
|
||||
m_aOut.write( tableHeaderCell( FIRSTGFX_TABLETITLE) );
|
||||
m_aOut.write( tableHeaderCell( SECONDGFX_TABLETITLE ) );
|
||||
m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
|
||||
m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
|
||||
|
||||
m_aOut.write( tableHeaderCell(DIFFER_BM_TABLETITLE) );
|
||||
m_aOut.write( tableHeaderCell(PIXELDIFF_BM_TABLETITLE ) );
|
||||
|
||||
m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
|
||||
|
||||
m_aOut.write( "</TR>" + ls);
|
||||
m_aOut.flush();
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void checkLine(StatusHelper _aStatus, boolean _bCurrentResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_aOut.write( "<TR>" + ls);
|
||||
String sLink = getHREF(FileHelper.getBasename(_aStatus.m_sOldGfx), FileHelper.getBasename(_aStatus.m_sOldGfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
String sPercent = String.valueOf(_aStatus.nPercent) + "%";
|
||||
if (_aStatus.nPercent > 0 && _aStatus.nPercent < 5)
|
||||
{
|
||||
sPercent += " (less 5% is ok)";
|
||||
}
|
||||
m_aOut.write(tableDataCell( sPercent ) );
|
||||
|
||||
if (_aStatus.m_sDiff_BM_Gfx == null)
|
||||
{
|
||||
sLink = "No diffs, therefore no moves";
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
m_aOut.write(tableDataCell( "" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx), FileHelper.getBasename(_aStatus.m_sDiff_BM_Gfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
String sPercent2 = String.valueOf(_aStatus.nPercent2) + "%";
|
||||
if (_aStatus.nPercent2 > 0 && _aStatus.nPercent2 < 5)
|
||||
{
|
||||
sPercent2 += " (less 5% is ok)";
|
||||
}
|
||||
m_aOut.write(tableDataCell( sPercent2 ) );
|
||||
}
|
||||
|
||||
// is the check positiv, in a defined range
|
||||
if (_bCurrentResult)
|
||||
{
|
||||
m_aOut.write(tableDataCell( "YES" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aOut.write(tableDataCell( "NO" ) );
|
||||
}
|
||||
|
||||
m_aOut.write( "</TR>" + ls);
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkDiffDiffSection(String _sDocumentName)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_aOut.write( "<H2>Results for the document " + _sDocumentName + "</H2>" + ls);
|
||||
|
||||
m_aOut.write( "<p>Legend:<br>");
|
||||
m_aOut.write( "</p>");
|
||||
|
||||
m_aOut.write( "<table class=\"infotable\">" + ls);
|
||||
|
||||
m_aOut.write( "<TR>" + ls);
|
||||
m_aOut.write( tableHeaderCell( "Source to actual difference" ) );
|
||||
m_aOut.write( tableHeaderCell( "Actual difference" ) );
|
||||
m_aOut.write( tableHeaderCell(DIFFER_TABLETITLE ) );
|
||||
m_aOut.write( tableHeaderCell(PIXELDIFF_TABLETITLE ) );
|
||||
|
||||
m_aOut.write( tableHeaderCell( OK_TABLETITLE) );
|
||||
|
||||
m_aOut.write( "</TR>" + ls);
|
||||
m_aOut.flush();
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDiffDiffLine(StatusHelper _aStatus, boolean _bCurrentResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_aOut.write( "<TR>" + ls);
|
||||
// the link to the old difference can't offer here
|
||||
|
||||
String sBasename = FileHelper.getBasename(m_sFilename);
|
||||
String sNew = sBasename.substring(m_sNamePrefix.length());
|
||||
|
||||
String sLink;
|
||||
sLink = getHREF(sNew, sNew);
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
sLink = getHREF(FileHelper.getBasename(_aStatus.m_sNewGfx), FileHelper.getBasename(_aStatus.m_sNewGfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
sLink = getHREF(FileHelper.getBasename(_aStatus.m_sDiffGfx), FileHelper.getBasename(_aStatus.m_sDiffGfx));
|
||||
m_aOut.write( tableDataCell(sLink) );
|
||||
|
||||
String sPercent = String.valueOf(_aStatus.nPercent) + "%";
|
||||
m_aOut.write(tableDataCell( sPercent ) );
|
||||
|
||||
// is the check positiv, in a defined range
|
||||
if (_bCurrentResult)
|
||||
{
|
||||
m_aOut.write(tableDataCell( "YES" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aOut.write(tableDataCell( "NO" ) );
|
||||
}
|
||||
|
||||
m_aOut.write( "</TR>" + ls);
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,10 +98,7 @@ public class INIOutputter
|
||||
}
|
||||
}
|
||||
|
||||
public void startSection(int _nNumber)
|
||||
{
|
||||
writeSection( "page" + String.valueOf(_nNumber));
|
||||
}
|
||||
|
||||
|
||||
public void close()
|
||||
{
|
||||
|
@ -267,91 +267,10 @@ class IniFile
|
||||
return sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
write back the ini file to the disk, only if there exist changes
|
||||
*/
|
||||
public void store()
|
||||
{
|
||||
if (m_bListContainUnsavedChanges == false)
|
||||
{
|
||||
// nothing has changed, so no need to store
|
||||
return;
|
||||
}
|
||||
|
||||
File aFile = new File(m_sFilename);
|
||||
if (aFile.exists())
|
||||
{
|
||||
aFile.delete();
|
||||
if (aFile.exists())
|
||||
{
|
||||
GlobalLogWriter.get().println("Couldn't delete the file " + m_sFilename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
RandomAccessFile aWriter = new RandomAccessFile(aFile, "rw");
|
||||
for (int i=0; i<m_aList.size();i++)
|
||||
{
|
||||
String sLine = getItem(i);
|
||||
aWriter.writeBytes(sLine);
|
||||
aWriter.writeByte('\n');
|
||||
}
|
||||
aWriter.close();
|
||||
}
|
||||
|
||||
catch (java.io.FileNotFoundException fne)
|
||||
{
|
||||
GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename);
|
||||
GlobalLogWriter.get().println("Message: " + fne.getMessage());
|
||||
}
|
||||
catch(java.io.IOException ie)
|
||||
{
|
||||
GlobalLogWriter.get().println("Exception occurs while writing to file " + m_sFilename);
|
||||
GlobalLogWriter.get().println("Message: " + ie.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
insert a value
|
||||
there are 3 cases
|
||||
1. section doesn't exist, goto end and insert a new section, insert a new key value pair
|
||||
2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there
|
||||
3. section exist and key exist, remove the old key and insert the key value pair at the same position
|
||||
*/
|
||||
public void insertValue(String _sSection, String _sKey, String _sValue)
|
||||
{
|
||||
int i = findSection(_sSection);
|
||||
if (i == -1)
|
||||
{
|
||||
// case 1: section doesn't exist
|
||||
String sFindSection = buildSectionName(_sSection);
|
||||
|
||||
m_aList.add(sFindSection);
|
||||
String sKeyValuePair = _sKey + "=" + _sValue;
|
||||
m_aList.add(sKeyValuePair);
|
||||
m_bListContainUnsavedChanges = true;
|
||||
return;
|
||||
}
|
||||
int j = findKeyFromKnownSection(i, _sKey);
|
||||
if (j == -1)
|
||||
{
|
||||
// case 2: section exist, but not the key
|
||||
j = findLastKnownKeyIndex(i, _sKey);
|
||||
String sKeyValuePair = _sKey + "=" + _sValue;
|
||||
m_aList.add(j, sKeyValuePair);
|
||||
m_bListContainUnsavedChanges = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// case 3: section exist, and also the key
|
||||
String sKeyValuePair = _sKey + "=" + _sValue;
|
||||
m_aList.set(j, sKeyValuePair);
|
||||
m_bListContainUnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,17 +56,7 @@ public class LISTOutputter
|
||||
}
|
||||
public String getFilename() {return m_sFilename;}
|
||||
|
||||
public void createHeader()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_aOut.write("# This file is automatically created by a convwatch run" + ls);
|
||||
m_aOut.write("# " + ls);
|
||||
}
|
||||
catch (java.io.IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeValue(String _sValue)
|
||||
{
|
||||
|
@ -787,35 +787,7 @@ public class OfficePrint {
|
||||
|
||||
// TODO: move this away!
|
||||
|
||||
static void showType(String _sInputURL, XMultiServiceFactory _xMSF)
|
||||
{
|
||||
if (_sInputURL.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_xMSF == null)
|
||||
{
|
||||
GlobalLogWriter.get().println("MultiServiceFactory not set.");
|
||||
return;
|
||||
}
|
||||
XTypeDetection aTypeDetection = null;
|
||||
try
|
||||
{
|
||||
Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
|
||||
aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj);
|
||||
}
|
||||
catch(com.sun.star.uno.Exception e)
|
||||
{
|
||||
GlobalLogWriter.get().println("Can't get com.sun.star.document.TypeDetection.");
|
||||
return;
|
||||
}
|
||||
if (aTypeDetection != null)
|
||||
{
|
||||
String sType = aTypeDetection.queryTypeByURL(_sInputURL);
|
||||
GlobalLogWriter.get().println("Type is: " + sType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -39,18 +39,6 @@ public class PRNCompare
|
||||
fs = System.getProperty("file.separator");
|
||||
}
|
||||
|
||||
String executeSynchronously(String _sCommand)
|
||||
{
|
||||
ProcessHandler aHandler = new ProcessHandler(_sCommand);
|
||||
aHandler.executeSynchronously();
|
||||
|
||||
String sText = aHandler.getOutputText();
|
||||
|
||||
GlobalLogWriter.get().println("Exitcode: " + String.valueOf(aHandler.getExitCode()));
|
||||
return sText;
|
||||
}
|
||||
|
||||
|
||||
private int getMaxNumOfFileEntry(String _sDirectory, String _sBasename)
|
||||
{
|
||||
// TODO: check if directory exist should be done earlier
|
||||
@ -140,18 +128,7 @@ public class PRNCompare
|
||||
return aList;
|
||||
}
|
||||
|
||||
public StatusHelper[] compare_new()
|
||||
{
|
||||
String[] aRefList = createJPEGFromPostscript(m_sOutputPath, m_sReferencePath, m_sReferenceFile, getResolutionInDPI());
|
||||
// TODO: Assume, that Postscript is already in the OutputPath, this may change.
|
||||
String[] aPSList = createJPEGFromPostscript(m_sOutputPath, m_sOutputPath, m_sPostScriptFile, getResolutionInDPI());
|
||||
StatusHelper[] aList = createDiffs(aRefList,
|
||||
aPSList,
|
||||
getMaxPages(),
|
||||
m_tUseBorderMove);
|
||||
|
||||
return aList;
|
||||
}
|
||||
|
||||
private static String getJPEGName(String _sOutputPath, String _sBasename, String _sGS_PageOutput)
|
||||
{
|
||||
|
@ -75,23 +75,7 @@ class CountNotBlack extends CountPixel
|
||||
|
||||
class graphics_stuff
|
||||
{
|
||||
public int stuff()
|
||||
{
|
||||
// (1) decoding
|
||||
int rgba = 0; // ...; // comes from PixelGrabber, BufferedImage.getRGB etc.
|
||||
int red = (rgba >> 16) & 0xff;
|
||||
int green = (rgba >> 8) & 0xff;
|
||||
int blue = rgba & 0xff;
|
||||
int alpha = (rgba >> 24) & 0xff;
|
||||
// (2) now modify red, green, blue and alpha as you like;
|
||||
// make sure that each of the four values stays in the
|
||||
// interval 0 to 255
|
||||
// ...
|
||||
// (3) and encode back to an int, e.g. to give it to MemoryImageSource or
|
||||
// BufferedImage.setRGB
|
||||
rgba = (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private static void countPixel(ImageHelper img, int _w, int _h, CountPixel _aPixelCounter)
|
||||
{
|
||||
|
@ -139,25 +139,8 @@ public class BuildID
|
||||
return sBuildID;
|
||||
}
|
||||
|
||||
public static String getMinor(String _sOfficePath)
|
||||
{
|
||||
final String sOfficePath = getOfficePath(_sOfficePath);
|
||||
final String sMinor = "m" + getBuildID(sOfficePath, "ProductMinor");
|
||||
return sMinor;
|
||||
}
|
||||
|
||||
public static String getCWSName(String _sOfficePath)
|
||||
{
|
||||
final String sOfficePath = getOfficePath(_sOfficePath);
|
||||
final String sBuildID = getBuildID(sOfficePath, "buildid");
|
||||
String sCWSName = "MWS";
|
||||
int nIdx = sBuildID.indexOf("[CWS:");
|
||||
if (nIdx > 0)
|
||||
{
|
||||
int nIdx2 = sBuildID.indexOf("]", nIdx);
|
||||
sCWSName = sBuildID.substring(nIdx + 5, nIdx2);
|
||||
}
|
||||
return sCWSName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -72,13 +72,7 @@ public class DirectoryHelper
|
||||
return a.m_aFileList.toArray();
|
||||
}
|
||||
|
||||
public static Object[] traverse( String _sDirectory, boolean _bRecursiveIsAllowed )
|
||||
{
|
||||
DirectoryHelper a = new DirectoryHelper();
|
||||
a.setRecursiveIsAllowed(_bRecursiveIsAllowed);
|
||||
a.traverse_impl(_sDirectory, null);
|
||||
return a.m_aFileList.toArray();
|
||||
}
|
||||
|
||||
|
||||
private void traverse_impl( String afileDirectory, FileFilter _aFileFilter )
|
||||
{
|
||||
|
@ -44,12 +44,7 @@ public class FileHelper
|
||||
|
||||
}
|
||||
|
||||
public static void MessageBox(String _sStr)
|
||||
{
|
||||
String sVersion = System.getProperty("java.version");
|
||||
String sOSName = System.getProperty("os.name");
|
||||
JOptionPane.showMessageDialog( null, _sStr, sVersion + " " + sOSName + " Hello World Debugger", JOptionPane.INFORMATION_MESSAGE );
|
||||
}
|
||||
|
||||
|
||||
public static boolean exists(String _sFile)
|
||||
{
|
||||
@ -66,27 +61,7 @@ public class FileHelper
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isDir(String _sDir)
|
||||
{
|
||||
if (_sDir == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
File aFile = new File(_sDir);
|
||||
if (aFile.exists() && aFile.isDirectory())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
GlobalLogWriter.println("Exception caught. FileHelper.isDir('" + _sDir + "')");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static String getBasename(String _sFilename)
|
||||
{
|
||||
@ -456,33 +431,7 @@ public class FileHelper
|
||||
};
|
||||
return aFileFilter;
|
||||
}
|
||||
/**
|
||||
* Within the directory run through, it's possible to say which file extension types should not
|
||||
* consider like '*.ini' because it's not a document.
|
||||
*
|
||||
* @return a FileFilter function
|
||||
*/
|
||||
public static FileFilter getFileFilterINI()
|
||||
{
|
||||
FileFilter aFileFilter = new FileFilter()
|
||||
{
|
||||
public boolean accept( File pathname )
|
||||
{
|
||||
String sPathname = pathname.getName().toLowerCase();
|
||||
if (sPathname.endsWith("index.ini"))
|
||||
{
|
||||
// don't consider the index.ini file
|
||||
return false;
|
||||
}
|
||||
if (sPathname.endsWith(".ini"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
return aFileFilter;
|
||||
}
|
||||
|
||||
|
||||
public static String appendPath(String _sPath, String _sRelativePathToAdd)
|
||||
{
|
||||
@ -616,12 +565,6 @@ public class FileHelper
|
||||
aIniFile.close();
|
||||
}
|
||||
|
||||
public static void addBasenameToPostscript(String _sOutputFilename)
|
||||
{
|
||||
String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "postscript.ini");
|
||||
String sBasename = FileHelper.getBasename(_sOutputFilename);
|
||||
addBasenameToFile(sIndexFilename, sBasename, "", "", "");
|
||||
}
|
||||
public static void addBasenameToIndex(String _sOutputFilename, String _sBasename, String _sCreator, String _sType, String _sSource)
|
||||
{
|
||||
String sIndexFilename = FileHelper.appendPath(_sOutputFilename, "index.ini");
|
||||
|
@ -409,10 +409,7 @@ public class IniFile implements Enumeration<String>
|
||||
insertValue(_sSection, _sKey, String.valueOf(_nValue));
|
||||
}
|
||||
|
||||
public void insertValue(String _sSection, String _sKey, long _nValue)
|
||||
{
|
||||
insertValue(_sSection, _sKey, String.valueOf(_nValue));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
insert a value
|
||||
|
@ -31,17 +31,7 @@ public class JPEGCreator extends EnhancedComplexTestCase
|
||||
return new String[]{"PostscriptOrPDFToJPEG"};
|
||||
}
|
||||
|
||||
/**
|
||||
* test function.
|
||||
*/
|
||||
public void PostscriptOrPDFToJPEG()
|
||||
{
|
||||
GlobalLogWriter.set(log);
|
||||
ParameterHelper aParam = new ParameterHelper(param);
|
||||
|
||||
// run through all documents found in Inputpath
|
||||
foreachPSorPDFinInputPath(aParam);
|
||||
}
|
||||
|
||||
|
||||
public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
|
||||
|
@ -162,57 +162,7 @@ public class MSOfficePostscriptCreator implements IOffice
|
||||
return false;
|
||||
}
|
||||
|
||||
public void storeToFileWithMSOffice( ParameterHelper _aGTA,
|
||||
String _sInputFile,
|
||||
String _sOutputFile) throws OfficeException, java.io.IOException
|
||||
{
|
||||
String sDocumentSuffix = FileHelper.getSuffix(_sInputFile);
|
||||
String sFilterName = _aGTA.getExportFilterName();
|
||||
ArrayList<String> aStartCommand = new ArrayList<String>();
|
||||
if (isWordDocument(sDocumentSuffix))
|
||||
{
|
||||
aStartCommand = createWordStoreHelper();
|
||||
}
|
||||
else if (isExcelDocument(sDocumentSuffix))
|
||||
{
|
||||
aStartCommand = createExcelStoreHelper();
|
||||
}
|
||||
else if (isPowerPointDocument(sDocumentSuffix))
|
||||
{
|
||||
}
|
||||
else if (sDocumentSuffix.toLowerCase().equals(".xml"))
|
||||
{
|
||||
// special case, if xml we prefer word, but with DEFAULT_XML_FORMAT_APP=excel it's changeable.
|
||||
String sDocFormat = getXMLDocumentFormat(_sInputFile);
|
||||
if (sDocFormat.equals("excel"))
|
||||
{
|
||||
aStartCommand = createExcelStoreHelper();
|
||||
}
|
||||
else
|
||||
{
|
||||
aStartCommand = createWordStoreHelper();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLogWriter.println("No Microsoft Office document format found.");
|
||||
|
||||
throw new WrongSuffixException("No MS office document format found.");
|
||||
}
|
||||
if (aStartCommand != null)
|
||||
{
|
||||
if (sFilterName == null)
|
||||
{
|
||||
// TODO: hardcoded FilterName in perl script
|
||||
sFilterName = ""; // xlXMLSpreadsheet";
|
||||
}
|
||||
|
||||
aStartCommand.add(_sInputFile);
|
||||
aStartCommand.add(sFilterName);
|
||||
aStartCommand.add(_sOutputFile);
|
||||
realStartCommand(aStartCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -576,74 +576,12 @@ public class OpenOfficePostscriptCreator implements IOffice
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true, if the reference (*.prrn file) based on given output path and given input path exist.
|
||||
* If OVERWRITE_REFERENCE is set, always return false.
|
||||
*/
|
||||
public boolean isReferenceExists(ParameterHelper _aGTA,
|
||||
String _sAbsoluteOutputPath,
|
||||
String _sAbsoluteInputFile)
|
||||
{
|
||||
if (! FileHelper.exists(_sAbsoluteInputFile))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String sInputFileBasename = FileHelper.getBasename(_sAbsoluteInputFile);
|
||||
String sOutputPath;
|
||||
if (_sAbsoluteOutputPath != null)
|
||||
{
|
||||
sOutputPath = _sAbsoluteOutputPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
String sInputPath = FileHelper.getPath(_sAbsoluteInputFile);
|
||||
sOutputPath = sInputPath;
|
||||
}
|
||||
|
||||
String sPrintFilename = FileHelper.getNameNoSuffix(sInputFileBasename);
|
||||
|
||||
String sAbsolutePrintFilename = FileHelper.appendPath(sOutputPath, sPrintFilename + ".prn");
|
||||
if (FileHelper.exists(sAbsolutePrintFilename) && _aGTA.getOverwrite() == false)
|
||||
{
|
||||
GlobalLogWriter.println("Reference already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// TODO: move this away!
|
||||
|
||||
void showType(String _sInputURL, XMultiServiceFactory _xMSF)
|
||||
{
|
||||
if (_sInputURL.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_xMSF == null)
|
||||
{
|
||||
GlobalLogWriter.println("MultiServiceFactory not set.");
|
||||
return;
|
||||
}
|
||||
XTypeDetection aTypeDetection = null;
|
||||
try
|
||||
{
|
||||
Object oObj = _xMSF.createInstance("com.sun.star.document.TypeDetection");
|
||||
aTypeDetection = UnoRuntime.queryInterface(XTypeDetection.class, oObj);
|
||||
}
|
||||
catch(com.sun.star.uno.Exception e)
|
||||
{
|
||||
GlobalLogWriter.println("Can't get com.sun.star.document.TypeDetection.");
|
||||
return;
|
||||
}
|
||||
if (aTypeDetection != null)
|
||||
{
|
||||
String sType = aTypeDetection.queryTypeByURL(_sInputURL);
|
||||
GlobalLogWriter.println("Type is: " + sType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -875,133 +813,7 @@ public class OpenOfficePostscriptCreator implements IOffice
|
||||
}
|
||||
|
||||
|
||||
public void convertDocument(String _sInputFile, String _sOutputPath, ParameterHelper _aGTA)
|
||||
{
|
||||
XMultiServiceFactory xMSF = _aGTA.getMultiServiceFactory();
|
||||
if (xMSF == null)
|
||||
{
|
||||
GlobalLogWriter.println("MultiServiceFactory in GraphicalTestArgument not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
String sInputURL = URLHelper.getFileURLFromSystemPath(_sInputFile);
|
||||
XComponent aDoc = loadFromURL( _aGTA, sInputURL);
|
||||
if (aDoc == null)
|
||||
{
|
||||
GlobalLogWriter.println("Can't load document '"+ sInputURL + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sOutputPath == null)
|
||||
{
|
||||
GlobalLogWriter.println("Outputpath not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (! isStoreAllowed())
|
||||
{
|
||||
GlobalLogWriter.println("It's not allowed to store, check Input/Output path.");
|
||||
return;
|
||||
}
|
||||
|
||||
XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, aDoc );
|
||||
|
||||
// store the document in an other directory
|
||||
XStorable xStorable = UnoRuntime.queryInterface( XStorable.class, aDoc);
|
||||
if (xStorable == null)
|
||||
{
|
||||
GlobalLogWriter.println("com.sun.star.frame.XStorable is null");
|
||||
return;
|
||||
}
|
||||
|
||||
String sFilterName = _aGTA.getExportFilterName();
|
||||
|
||||
ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
|
||||
|
||||
String sExtension = "";
|
||||
|
||||
if (sFilterName != null && sFilterName.length() > 0)
|
||||
{
|
||||
String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
|
||||
String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
|
||||
|
||||
GlobalLogWriter.println("Filter detection:");
|
||||
// check if service name from file filter is the same as from the loaded document
|
||||
boolean bServiceFailed = false;
|
||||
if (sServiceName == null || sInternalFilterName == null)
|
||||
{
|
||||
GlobalLogWriter.println("Given FilterName '" + sFilterName + "' seems to be unknown.");
|
||||
bServiceFailed = true;
|
||||
}
|
||||
if (! xServiceInfo.supportsService(sServiceName))
|
||||
{
|
||||
GlobalLogWriter.println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
|
||||
bServiceFailed = true;
|
||||
}
|
||||
if (bServiceFailed == true)
|
||||
{
|
||||
GlobalLogWriter.println("Please check '" + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + "' in the property file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sInternalFilterName != null && sInternalFilterName.length() > 0)
|
||||
{
|
||||
// get the FileExtension, by the filter name, if we don't get a file extension
|
||||
// we assume the is also no right filter name.
|
||||
sExtension = getFileExtension(sInternalFilterName, xMSF);
|
||||
if (sExtension == null)
|
||||
{
|
||||
GlobalLogWriter.println("Can't found an extension for filtername, take it from the source.");
|
||||
}
|
||||
}
|
||||
|
||||
PropertyValue Arg = new PropertyValue();
|
||||
Arg.Name = "FilterName";
|
||||
Arg.Value = sFilterName;
|
||||
aPropertyList.add(Arg);
|
||||
showProperty(Arg);
|
||||
GlobalLogWriter.println("FilterName is set to: " + sFilterName);
|
||||
}
|
||||
|
||||
String sOutputURL = "";
|
||||
try
|
||||
{
|
||||
// create the new filename with the extension, which is ok to the file format
|
||||
String sInputFileBasename = FileHelper.getBasename(_sInputFile);
|
||||
String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
|
||||
String fs = System.getProperty("file.separator");
|
||||
String sOutputFile = _sOutputPath;
|
||||
if (! sOutputFile.endsWith(fs))
|
||||
{
|
||||
sOutputFile += fs;
|
||||
}
|
||||
if (sExtension != null && sExtension.length() > 0)
|
||||
{
|
||||
sOutputFile += sInputFileNameNoSuffix + "." + sExtension;
|
||||
}
|
||||
else
|
||||
{
|
||||
sOutputFile += sInputFileBasename;
|
||||
}
|
||||
|
||||
if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
|
||||
{
|
||||
GlobalLogWriter.println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
|
||||
return;
|
||||
}
|
||||
|
||||
sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
|
||||
|
||||
GlobalLogWriter.println("Store document as '" + sOutputURL + "'");
|
||||
xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
|
||||
GlobalLogWriter.println("Document stored.");
|
||||
}
|
||||
catch (com.sun.star.io.IOException e)
|
||||
{
|
||||
GlobalLogWriter.println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OfficeProvider m_aProvider = null;
|
||||
private void startOffice()
|
||||
@ -1041,12 +853,8 @@ public class OpenOfficePostscriptCreator implements IOffice
|
||||
}
|
||||
}
|
||||
|
||||
public void disallowStore()
|
||||
{
|
||||
}
|
||||
public void allowStore()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public boolean isStoreAllowed()
|
||||
{
|
||||
return false;
|
||||
|
@ -34,19 +34,7 @@ class CountNotWhite extends CountPixel
|
||||
{
|
||||
}
|
||||
|
||||
public void countold(final int pixel)
|
||||
{
|
||||
// final int alpha = (pixel >> 24) & 0xff;
|
||||
final int red = (pixel >> 16) & 0xff;
|
||||
final int green = (pixel >> 8) & 0xff;
|
||||
final int blue = (pixel ) & 0xff;
|
||||
|
||||
if (red == 0xff && green == 0xff && blue == 0xff)
|
||||
{
|
||||
return;
|
||||
}
|
||||
++m_nCount;
|
||||
}
|
||||
@Override
|
||||
public void count(final int pixel)
|
||||
{
|
||||
@ -79,19 +67,7 @@ class CountNotBlack extends CountPixel
|
||||
{
|
||||
}
|
||||
|
||||
public void countold(final int pixel)
|
||||
{
|
||||
// final int alpha = (pixel >> 24) & 0xff;
|
||||
final int red = (pixel >> 16) & 0xff;
|
||||
final int green = (pixel >> 8) & 0xff;
|
||||
final int blue = (pixel ) & 0xff;
|
||||
|
||||
if (red == 0x00 && green == 0x00 && blue == 0x00)
|
||||
{
|
||||
return;
|
||||
}
|
||||
++m_nCount;
|
||||
}
|
||||
@Override
|
||||
public void count(final int pixel)
|
||||
{
|
||||
|
@ -181,28 +181,10 @@ public class ConfigHelper
|
||||
}
|
||||
|
||||
|
||||
public static Object readDirectKey(XMultiServiceFactory xSMGR ,
|
||||
String sConfigFile,
|
||||
String sRelPath ,
|
||||
String sKey )
|
||||
throws com.sun.star.uno.Exception
|
||||
{
|
||||
ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, true);
|
||||
return aConfig.readRelativeKey(sRelPath, sKey);
|
||||
}
|
||||
|
||||
|
||||
public static void writeDirectKey(XMultiServiceFactory xSMGR ,
|
||||
String sConfigFile,
|
||||
String sRelPath ,
|
||||
String sKey ,
|
||||
Object aValue )
|
||||
throws com.sun.star.uno.Exception
|
||||
{
|
||||
ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, false);
|
||||
aConfig.writeRelativeKey(sRelPath, sKey, aValue);
|
||||
aConfig.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -71,14 +71,7 @@ public class ConfigurationRead {
|
||||
this(xMSF, "org.openoffice.Setup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the node with this hierarchical name exist?
|
||||
* @param name The hierarchical name of a subnode.
|
||||
* @return True, if the node exists.
|
||||
*/
|
||||
public boolean hasByHieracrhicalName(String name) {
|
||||
return root.hasByHierarchicalName(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -91,28 +84,7 @@ public class ConfigurationRead {
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all elements of this node
|
||||
* @param name The name of the node
|
||||
* @return All elements of this node (as hierarchical names).
|
||||
*/
|
||||
public String[] getSubNodeNames(String name) {
|
||||
String[]names = null;
|
||||
try {
|
||||
|
||||
Object next = root.getByHierarchicalName(name);
|
||||
XNameAccess x = UnoRuntime.queryInterface(
|
||||
XNameAccess.class, next);
|
||||
names = x.getElementNames();
|
||||
for (int i=0; i< names.length; i++) {
|
||||
names[i] = name + "/" + names[i];
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
//just return null, if there are no further nodes
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contents of a node by its hierarchical name.
|
||||
|
@ -92,19 +92,7 @@ public class FileTools {
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
/**
|
||||
* Deletes all files and subdirectories under dir and the directory itself.
|
||||
* Returns true if all deletions were successful.
|
||||
* If the deletion fails, the method the method continues to delete rest
|
||||
* of the files and returns false.
|
||||
* @return Returns true if all deletions were successful, else false.
|
||||
* @param dir the directory to delete
|
||||
*/
|
||||
public static boolean deleteDir(File dir) {
|
||||
|
||||
// The directory is now empty so delete it
|
||||
return cleanDir(dir);
|
||||
}
|
||||
|
||||
public static boolean cleanDir(File dir)
|
||||
{
|
||||
|
@ -576,18 +576,7 @@ public class ProcessHandler
|
||||
flushInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is useful when the process was executed
|
||||
* asynchronously. Waits for process to exit and return
|
||||
* its result.
|
||||
*
|
||||
* @return <code>true</code> if process correctly exited
|
||||
* (exit code doesn't affect to this result).
|
||||
*/
|
||||
public boolean waitFor()
|
||||
{
|
||||
return waitFor(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is useful when the process was executed
|
||||
@ -737,20 +726,7 @@ public class ProcessHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the string specified to sdtin of external
|
||||
* command. '\n' is not added so if you need you
|
||||
* should terminate the string with '\n'. <p>
|
||||
*
|
||||
* The method can also be called before the command
|
||||
* starts its execution. Then the text is buffered
|
||||
* and transferred to command when it will be started.
|
||||
*/
|
||||
public void printInputText(String str)
|
||||
{
|
||||
stdInBuff += str;
|
||||
flushInput();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns information about was the command started or
|
||||
@ -940,15 +916,5 @@ public class ProcessHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* to stop the extra thread, before he will kill a running office. This will stop the thread.
|
||||
*/
|
||||
public void stopWatcher()
|
||||
{
|
||||
if (m_aWatcher != null)
|
||||
{
|
||||
m_aWatcher.holdOn();
|
||||
shortWait(5000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,25 +71,7 @@ public class StringHelper
|
||||
return sNewPath;
|
||||
}
|
||||
|
||||
public static String doubleQuoteIfNeed(String _sStr)
|
||||
{
|
||||
if (_sStr.startsWith("\"") && _sStr.endsWith("\""))
|
||||
{
|
||||
// don't quote twice
|
||||
return _sStr;
|
||||
}
|
||||
if (_sStr.indexOf(" ") == -1)
|
||||
{
|
||||
// don't quote, if there is no space in name
|
||||
return _sStr;
|
||||
}
|
||||
if (_sStr.indexOf("%") != -1)
|
||||
{
|
||||
return singleQuote(_sStr);
|
||||
}
|
||||
|
||||
return doubleQuote(_sStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a value to a string with a given length, if the len is greater the len of the value string representation
|
||||
|
@ -144,84 +144,11 @@ public class URLHelper
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The same as getURLWithProtocolFromSystemPath() before but uses string parameter instead
|
||||
* of a File types. It exist to supress converting of necessary parameters in the
|
||||
* outside code. But of course getURLWithProtocolFromSystemPath(File,File,String) will be
|
||||
* a little bit faster then this method ...
|
||||
*
|
||||
* @param sSystemPath
|
||||
* represent the file in system notation
|
||||
*
|
||||
* @param sBasePath
|
||||
* define the base path of the aSystemPath value,
|
||||
* which must be replaced with the value of "sServerPath".
|
||||
*
|
||||
* @param sServerPath
|
||||
* Will be used to replace sBasePath.
|
||||
*
|
||||
* @example
|
||||
* System Path = "d:\test\file.txt"
|
||||
* Base Path = "d:\test"
|
||||
* Server Path = "http://alaska:8000"
|
||||
* => "http://alaska:8000/file.txt"
|
||||
*
|
||||
* @return [String]
|
||||
* an url which represent the given system path
|
||||
* and uses the given protocol
|
||||
*/
|
||||
public static String getURLWithProtocolFromSystemPath( String sSystemPath, String sBasePath, String sServerPath )
|
||||
{
|
||||
return getURLWithProtocolFromSystemPath(new File(sSystemPath), new File(sBasePath), sServerPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This convert an URL (formated as a string) to a struct com.sun.star.util.URL.
|
||||
* It use a special service to do that: the URLTransformer.
|
||||
* Because some API calls need it and it's not allowed to set "Complete"
|
||||
* part of the util struct only. The URL must be parsed.
|
||||
*
|
||||
* @param sURL
|
||||
* URL for parsing in string notation
|
||||
*
|
||||
* @return [com.sun.star.util.URL]
|
||||
* URL in UNO struct notation
|
||||
*/
|
||||
public static com.sun.star.util.URL parseURL(XURLTransformer xParser, String sURL)
|
||||
{
|
||||
com.sun.star.util.URL aURL = null;
|
||||
|
||||
if (sURL==null || sURL.equals(""))
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
// Create special service for parsing of given URL.
|
||||
/* com.sun.star.util.XURLTransformer xParser = (com.sun.star.util.XURLTransformer)OfficeConnect.createRemoteInstance(
|
||||
com.sun.star.util.XURLTransformer.class,
|
||||
"com.sun.star.util.URLTransformer");
|
||||
*/
|
||||
// Because it's an in/out parameter we must use an array of URL objects.
|
||||
com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1];
|
||||
aParseURL[0] = new com.sun.star.util.URL();
|
||||
aParseURL[0].Complete = sURL;
|
||||
|
||||
// Parse the URL
|
||||
xParser.parseStrict(aParseURL);
|
||||
|
||||
aURL = aParseURL[0];
|
||||
}
|
||||
catch(com.sun.star.uno.RuntimeException exRuntime)
|
||||
{
|
||||
// Any UNO method of this scope can throw this exception.
|
||||
// Reset the return value only.
|
||||
aURL = null;
|
||||
}
|
||||
|
||||
return aURL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -170,47 +170,9 @@ public class Parameters implements XPropertySet {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getString(XPropertySet props, String name) {
|
||||
try {
|
||||
return (String)props.getPropertyValue(name);
|
||||
} catch (UnknownPropertyException e) {
|
||||
return null;
|
||||
} catch (WrappedTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object get(XPropertySet props, String name) {
|
||||
try {
|
||||
return props.getPropertyValue(name);
|
||||
} catch (UnknownPropertyException e) {
|
||||
return null;
|
||||
} catch (WrappedTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> toMap(XPropertySet props) {
|
||||
HashMap<String, Object> result = new HashMap<String, Object>(10);
|
||||
|
||||
XPropertySetInfo setInfo = props.getPropertySetInfo();
|
||||
Property[] properties = setInfo.getProperties();
|
||||
|
||||
for (int i = 0; i < properties.length; i++) {
|
||||
String name = properties[i].Name;
|
||||
Object value;
|
||||
|
||||
try {
|
||||
value = props.getPropertyValue(name);
|
||||
} catch (WrappedTargetException e) {
|
||||
continue;
|
||||
} catch (UnknownPropertyException e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.put(name, value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -86,13 +86,7 @@ public class Status extends SimpleStatus {
|
||||
return new Status( SKIPPED, state );
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a factory method for creating a Status representing that the
|
||||
* result of the activity was excluded. It always has FAILED state.
|
||||
*/
|
||||
public static Status excluded() {
|
||||
return new Status( EXCLUDED, false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Status representing an activity failed for an arbitrary reason.
|
||||
|
@ -262,53 +262,6 @@ public class AccessibilityTools {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p>
|
||||
* @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet
|
||||
* @param cellName The name of a cell like "A5"
|
||||
* @return the <CODE>XAccessiblecontext</CODE> of the named cell
|
||||
*/
|
||||
public static XAccessibleContext getSheetCell(XAccessibleContext xSheetAcc, String cellName){
|
||||
|
||||
int cellIndex = 0;
|
||||
int column =0;
|
||||
int charMem = 0;
|
||||
for (int n=0; n<cellName.length(); n++){
|
||||
String cha = cellName.substring(n,n+1);
|
||||
System.out.println("char: " + cha + " ");
|
||||
|
||||
byte[] bytes = cha.getBytes();
|
||||
|
||||
if ((bytes[0] >= 'A') && (bytes[0] <= 'Z')){
|
||||
charMem = bytes[0]-64;
|
||||
column++;
|
||||
if ( column == 2 ){
|
||||
cellIndex += charMem * 26;
|
||||
}
|
||||
cellIndex= cellIndex+ (bytes[0]-65);
|
||||
} else {
|
||||
String sNumb = cellName.substring(n, cellName.length());
|
||||
int iNumb = Integer.valueOf(sNumb).intValue();
|
||||
cellIndex += (iNumb-1) * 256;
|
||||
System.out.println("numb:" + (iNumb-1) * 256);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
XAccessibleContext ac = xSheetAcc.getAccessibleChild(cellIndex).getAccessibleContext();
|
||||
System.out.println(ac.getAccessibleRole() + "," +
|
||||
ac.getAccessibleName() + "(" +
|
||||
ac.getAccessibleDescription() + "):" +
|
||||
utils.getImplName(ac));
|
||||
|
||||
return ac;
|
||||
} catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
|
||||
System.out.println("ERROR: could not get child at index " + cellIndex +"': " + ex.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void printAccessibleTree(PrintWriter log, XAccessible xacc, boolean debugIsActive) {
|
||||
debug = debugIsActive;
|
||||
if (debug) printAccessibleTree(log, xacc, "");
|
||||
|
@ -280,12 +280,7 @@ public class DBTools {
|
||||
*/
|
||||
public DataSourceInfo newDataSourceInfo() { return new DataSourceInfo() ;}
|
||||
|
||||
/**
|
||||
* Returns new instance of <code>DataSourceInfo</code> class.
|
||||
*/
|
||||
public DataSourceInfo newDataSourceInfo(Object dataSource) {
|
||||
return new DataSourceInfo(dataSource);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers the datasource on the specified name in
|
||||
@ -324,75 +319,9 @@ public class DBTools {
|
||||
registerDB(name, dataSource) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* RESERVED. Not used.
|
||||
*/
|
||||
public XConnection connectToTextDB(String contextName,
|
||||
String dbDir, String fileExtension)
|
||||
throws com.sun.star.uno.Exception {
|
||||
|
||||
try {
|
||||
XInterface newSource = (XInterface) xMSF.createInstance
|
||||
("com.sun.star.sdb.DataSource") ;
|
||||
|
||||
XPropertySet xSrcProp = UnoRuntime.queryInterface(XPropertySet.class, newSource);
|
||||
|
||||
xSrcProp.setPropertyValue("URL", "sdbc:text:" + dirToUrl(dbDir));
|
||||
|
||||
PropertyValue extParam = new PropertyValue() ;
|
||||
extParam.Name = "EXT" ;
|
||||
extParam.Value = fileExtension ;
|
||||
|
||||
xSrcProp.setPropertyValue("Info", new PropertyValue[] {extParam}) ;
|
||||
|
||||
dbContext.registerObject(contextName, newSource) ;
|
||||
|
||||
Object handler = xMSF.createInstance("com.sun.star.sdb.InteractionHandler");
|
||||
XInteractionHandler xHandler = UnoRuntime.queryInterface(XInteractionHandler.class, handler) ;
|
||||
|
||||
XCompletedConnection xSrcCon = UnoRuntime.queryInterface(XCompletedConnection.class, newSource) ;
|
||||
|
||||
XConnection con = xSrcCon.connectWithCompletion(xHandler) ;
|
||||
|
||||
return con ;
|
||||
} finally {
|
||||
try {
|
||||
dbContext.revokeObject(contextName) ;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers DBase database (directory with DBF files) in the
|
||||
* global DB context, then connects to it.
|
||||
* @param contextName Name under which DB will be registered.
|
||||
* @param dbDir The directory with DBF tables.
|
||||
* @return Connection to the DB.
|
||||
*/
|
||||
public XConnection connectToDBase(String contextName,
|
||||
String dbDir)
|
||||
throws com.sun.star.uno.Exception {
|
||||
|
||||
try {
|
||||
XInterface newSource = (XInterface) xMSF.createInstance
|
||||
("com.sun.star.sdb.DataSource") ;
|
||||
|
||||
XPropertySet xSrcProp = UnoRuntime.queryInterface(XPropertySet.class, newSource);
|
||||
xSrcProp.setPropertyValue("URL", "sdbc:dbase:" + dirToUrl(dbDir));
|
||||
|
||||
dbContext.registerObject(contextName, newSource) ;
|
||||
|
||||
XConnection con = connectToSource(newSource) ;
|
||||
|
||||
return con ;
|
||||
} catch(com.sun.star.uno.Exception e) {
|
||||
try {
|
||||
dbContext.revokeObject(contextName) ;
|
||||
} catch (Exception ex) {}
|
||||
|
||||
throw e ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs connection to DataSource specified.
|
||||
@ -461,23 +390,7 @@ public class DBTools {
|
||||
return src ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to <code>DataSource</code> specially created for testing.
|
||||
* This source always has name <code>'APITestDatabase'</code> and it
|
||||
* is registered in subdirectory <code>TestDB</code> of directory
|
||||
* <code>docPath</code> which is supposed to be a directory with test
|
||||
* documents, but can be any other (it must have subdirectory with DBF
|
||||
* tables). If such data source doesn't exists or exists with
|
||||
* different URL it is recreated and reregistered. Finally connection
|
||||
* performed.
|
||||
* @param docPath Path to database <code>TestDB</code> directory.
|
||||
* @return Connection to test database.
|
||||
*/
|
||||
public XConnection connectToTestDB(String docPath)
|
||||
throws com.sun.star.uno.Exception {
|
||||
|
||||
return connectToSource(registerTestDB(docPath)) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empties the table in the specified source.
|
||||
@ -584,44 +497,9 @@ public class DBTools {
|
||||
xClose.close() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes test table specified of the connection specified.
|
||||
* Deletes all record from table, and then inserts data from
|
||||
* <code>TST_TABLE_VALUES</code> constant array. <p>
|
||||
* Test table has some predefined format which includes as much
|
||||
* field types as possible. For every column type constants
|
||||
* {@link #TST_STRING TST_STRING}, {@link #TST_INT TST_INT}, etc.
|
||||
* are declared for column index fast find.
|
||||
* @param con Connection to data source where test table exists.
|
||||
* @param table Test table name.
|
||||
*/
|
||||
public void initializeTestTable(XConnection con, String table)
|
||||
throws com.sun.star.sdbc.SQLException {
|
||||
|
||||
deleteAllRows(con, table) ;
|
||||
|
||||
for (int i = 0; i < TST_TABLE_VALUES.length; i++) {
|
||||
addRowToTestTable(con, table, TST_TABLE_VALUES[i], TST_STREAM_LENGTHS[i]) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints full info about currently registered DataSource's.
|
||||
*/
|
||||
public void printRegisteredDatabasesInfo(PrintWriter out) {
|
||||
XEnumerationAccess dbContEA = UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ;
|
||||
|
||||
XEnumeration xEnum = dbContEA.createEnumeration() ;
|
||||
|
||||
out.println("DatabaseContext registered DataSource's :") ;
|
||||
while (xEnum.hasMoreElements()) {
|
||||
try {
|
||||
DataSourceInfo inf = new DataSourceInfo(xEnum.nextElement()) ;
|
||||
inf.printInfo(out) ;
|
||||
} catch (com.sun.star.container.NoSuchElementException e) {}
|
||||
catch (com.sun.star.lang.WrappedTargetException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert system pathname to SOffice URL string
|
||||
|
@ -101,17 +101,7 @@ public class DesktopTools
|
||||
return xDesktop.getComponents().createEnumeration();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current component on the desktop
|
||||
* @param xMSF the XMultiServiceFactory
|
||||
* @return XComponent of the current component on the desktop
|
||||
*/
|
||||
public static XComponent getCurrentComponent(XMultiServiceFactory xMSF)
|
||||
{
|
||||
XDesktop xDesktop = UnoRuntime.queryInterface(
|
||||
XDesktop.class, createDesktop(xMSF));
|
||||
return xDesktop.getCurrentComponent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the current component on the desktop
|
||||
@ -460,15 +450,7 @@ public class DesktopTools
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to typo deprecated
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static void bringWindowToFromt(XModel xModel)
|
||||
{
|
||||
bringWindowToFront(xModel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function brings a document to the front.<P>
|
||||
|
@ -130,21 +130,4 @@ public class DrawTools {
|
||||
return oShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a XShape and adds it to the documents
|
||||
* first drawpage
|
||||
* @param oDoc the document
|
||||
* @param height the height of the shape
|
||||
* @param width the width of the shape
|
||||
* @param x the x-position of the shape
|
||||
* @param y the y-position of the shape
|
||||
* @param kind the kind of the shape ('Ellipse', 'Line' or 'Rectangle')
|
||||
*/
|
||||
public void addShape( XComponent oDoc, int height, int width, int x,
|
||||
int y, String kind ) {
|
||||
|
||||
getShapes(getDrawPage(oDoc,0)).add(createShape( oDoc, height, width, x,
|
||||
y, kind ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,23 +59,6 @@ public class DynamicClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of a class. The constructor matching to the
|
||||
* arguments is used and the arguments are given to this constructor.
|
||||
* @param className The class to instantiate.
|
||||
* @param ctorArgs Arguments for the constructor.
|
||||
* @return The instance of the class.
|
||||
*/
|
||||
public Object getInstance(String className, Object[] ctorArgs)
|
||||
throws IllegalArgumentException {
|
||||
Class<?>[] ctorType = new Class[ctorArgs.length];
|
||||
for(int i=0; i<ctorType.length; i++) {
|
||||
ctorType[i] = ctorArgs[i].getClass();
|
||||
}
|
||||
return getInstance(className, ctorType, ctorArgs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of a class. The constructor matching to the
|
||||
* given calss types is used and the instance is created using the arguments
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user