This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push: new 7958887 Fixed typos, removed whitespace 7958887 is described below commit 7958887939f24d3946e112c28ba21a4a0c201414 Author: mseidel <msei...@apache.org> AuthorDate: Wed Mar 10 18:57:18 2021 +0100 Fixed typos, removed whitespace (cherry picked from commit 65e976d8aa33de618e4243063b22a5388da39a96) --- main/offapi/com/sun/star/chart/ChartAxis.idl | 396 +++++++-------- .../tests/java/mod/_dbaccess/OQueryDesign.java | 531 +++++++++++---------- .../tests/java/mod/_forms/GenericModelTest.java | 154 +++--- 3 files changed, 542 insertions(+), 539 deletions(-) diff --git a/main/offapi/com/sun/star/chart/ChartAxis.idl b/main/offapi/com/sun/star/chart/ChartAxis.idl index b3aa30e..7d32635 100644 --- a/main/offapi/com/sun/star/chart/ChartAxis.idl +++ b/main/offapi/com/sun/star/chart/ChartAxis.idl @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,330 +7,330 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ -#ifndef __com_sun_star_chart_ChartAxis_idl__ -#define __com_sun_star_chart_ChartAxis_idl__ - -#ifndef __com_sun_star_drawing_LineProperties_idl__ -#include <com/sun/star/drawing/LineProperties.idl> -#endif - -#ifndef __com_sun_star_style_CharacterProperties_idl__ -#include <com/sun/star/style/CharacterProperties.idl> -#endif - -#ifndef __com_sun_star_beans_XPropertySet_idl__ -#include <com/sun/star/beans/XPropertySet.idl> -#endif - -#ifndef __com_sun_star_chart_ChartAxisArrangeOrderType_idl__ -#include <com/sun/star/chart/ChartAxisArrangeOrderType.idl> -#endif +#ifndef __com_sun_star_chart_ChartAxis_idl__ +#define __com_sun_star_chart_ChartAxis_idl__ -#ifndef __com_sun_star_chart_ChartAxisPosition_idl__ -#include <com/sun/star/chart/ChartAxisPosition.idl> -#endif +#ifndef __com_sun_star_drawing_LineProperties_idl__ +#include <com/sun/star/drawing/LineProperties.idl> +#endif -#ifndef __com_sun_star_chart_ChartAxisLabelPosition_idl__ -#include <com/sun/star/chart/ChartAxisLabelPosition.idl> -#endif +#ifndef __com_sun_star_style_CharacterProperties_idl__ +#include <com/sun/star/style/CharacterProperties.idl> +#endif + +#ifndef __com_sun_star_beans_XPropertySet_idl__ +#include <com/sun/star/beans/XPropertySet.idl> +#endif + +#ifndef __com_sun_star_chart_ChartAxisArrangeOrderType_idl__ +#include <com/sun/star/chart/ChartAxisArrangeOrderType.idl> +#endif + +#ifndef __com_sun_star_chart_ChartAxisPosition_idl__ +#include <com/sun/star/chart/ChartAxisPosition.idl> +#endif -#ifndef __com_sun_star_chart_ChartAxisMarkPosition_idl__ -#include <com/sun/star/chart/ChartAxisMarkPosition.idl> +#ifndef __com_sun_star_chart_ChartAxisLabelPosition_idl__ +#include <com/sun/star/chart/ChartAxisLabelPosition.idl> #endif -#ifndef __com_sun_star_chart_ChartAxisType_idl__ -#include <com/sun/star/chart/ChartAxisType.idl> +#ifndef __com_sun_star_chart_ChartAxisMarkPosition_idl__ +#include <com/sun/star/chart/ChartAxisMarkPosition.idl> #endif -#ifndef __com_sun_star_chart_TimeIncrement_idl__ -#include <com/sun/star/chart/TimeIncrement.idl> +#ifndef __com_sun_star_chart_ChartAxisType_idl__ +#include <com/sun/star/chart/ChartAxisType.idl> #endif -#ifndef __com_sun_star_chart_XAxis_idl__ -#include <com/sun/star/chart/XAxis.idl> +#ifndef __com_sun_star_chart_TimeIncrement_idl__ +#include <com/sun/star/chart/TimeIncrement.idl> +#endif + +#ifndef __com_sun_star_chart_XAxis_idl__ +#include <com/sun/star/chart/XAxis.idl> #endif #ifndef _com_sun_star_xml_UserDefinedAttributeSupplier_idl_ #include <com/sun/star/xml/UserDefinedAttributeSupplier.idl> #endif - -//============================================================================= - - module com { module sun { module star { module chart { - -//============================================================================= - + +//============================================================================= + + module com { module sun { module star { module chart { + +//============================================================================= + /** Specifies the axes in a diagram. - + <p>Note: The text properties correlate to all axis description elements, not to just a single text element.</p> */ published service ChartAxis -{ +{ /** set the properties for the entire axis line as well as for the - tick marks. + tick marks. */ - service com::sun::star::drawing::LineProperties; - + service com::sun::star::drawing::LineProperties; + /** set the properties for all text labels of the axis */ - service com::sun::star::style::CharacterProperties; - + service com::sun::star::style::CharacterProperties; + /** If a <type>ChartAxis</type> may be stored as XML element, this - service should be supported in order to preserve unparsed XML - attributes. - - @since OpenOffice 1.1.2 - */ - [optional] service com::sun::star::xml::UserDefinedAttributeSupplier; - - /** Access to the sub elements of an axis like title and grids. - @since OpenOffice 3.4 - */ - [optional] interface com::sun::star::chart::XAxis; - - interface com::sun::star::beans::XPropertySet; - - //------------------------------------------------------------------------- - /** Properties for scaling: - */ - - //------------------------------------------------------------------------- - + service should be supported in order to preserve unparsed XML + attributes. + + @since OpenOffice 1.1.2 + */ + [optional] service com::sun::star::xml::UserDefinedAttributeSupplier; + + /** Access to the sub elements of an axis like title and grids. + @since OpenOffice 3.4 + */ + [optional] interface com::sun::star::chart::XAxis; + + interface com::sun::star::beans::XPropertySet; + + //------------------------------------------------------------------------- + /** Properties for scaling: + */ + + //------------------------------------------------------------------------- + /** Contains the maximum value for the axis scale. */ - [optional, property] double Max; - - //------------------------------------------------------------------------- - + [optional, property] double Max; + + //------------------------------------------------------------------------- + /** Contains the minimum value for the axis scale. */ - [optional, property] double Min; - - //------------------------------------------------------------------------- - + [optional, property] double Min; + + //------------------------------------------------------------------------- + /** Contains the distance between the main tick marks. */ - [optional, property] double StepMain; - - //------------------------------------------------------------------------- - - /** - Contains the number of help intervals within a main interval. E.g. a StepHelpCount of 5 divides - the main interval into 5 pieces and thus producces 4 help tick marks. - */ - [optional, property] long StepHelpCount; - - //------------------------------------------------------------------------- - + [optional, property] double StepMain; + + //------------------------------------------------------------------------- + + /** + Contains the number of help intervals within a main interval. E.g. a StepHelpCount of 5 divides + the main interval into 5 pieces and thus produces 4 help tick marks. + */ + [optional, property] long StepHelpCount; + + //------------------------------------------------------------------------- + /** @deprecated - User property StepHelpCount instead - Contains the distance between the help tick marks. - */ - [optional, property] double StepHelp; - - //------------------------------------------------------------------------- - - /** The maximium value of the axis scale is calculated by the chart if + User property StepHelpCount instead + Contains the distance between the help tick marks. + */ + [optional, property] double StepHelp; + + //------------------------------------------------------------------------- + + /** The maximum value of the axis scale is calculated by the chart if this property is <TRUE/>. */ - [optional, property] boolean AutoMax; - - //------------------------------------------------------------------------- - + [optional, property] boolean AutoMax; + + //------------------------------------------------------------------------- + /** The minimum value of the axis scale is calculated by the chart if this property is <TRUE/>. */ - [optional, property] boolean AutoMin; - + [optional, property] boolean AutoMin; + //------------------------------------------------------------------------- /** The distance between the main tick marks is calculated by the chart if this property is <TRUE/>. */ - [optional, property] boolean AutoStepMain; + [optional, property] boolean AutoStepMain; - //------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** The number of help intervals within a main interval is calculated by the chart if this property is <TRUE/>. - */ - [optional, property] boolean AutoStepHelp; - - - //------------------------------------------------------------------------- - + */ + [optional, property] boolean AutoStepHelp; + + + //------------------------------------------------------------------------- + /** Determines if the axis is scaled logarithmically or not (linear). */ - [optional, property] boolean Logarithmic; + [optional, property] boolean Logarithmic; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** determines which type of axis this is, e.g. a date-axis or a category-axis @see ChartAxisType - @since OpenOffice 3.4 + @since OpenOffice 3.4 */ [optional, property] long AxisType; - //------------------------------------------------------------------------- - + //------------------------------------------------------------------------- + /** if the current axis is a date-axis the intervals are chosen as given with TimeIncrement - @since OpenOffice 3.4 + @since OpenOffice 3.4 */ [optional, maybevoid, property] TimeIncrement TimeIncrement; - //------------------------------------------------------------------------- - + //------------------------------------------------------------------------- + /** Determines if the axis orientation is mathematical or reversed. */ [optional, property] boolean ReverseDirection; - //------------------------------------------------------------------------- - + //------------------------------------------------------------------------- + /** Determines where the axis crosses the other axis. */ - [optional, property] com::sun::star::chart::ChartAxisPosition CrossoverPosition; + [optional, property] com::sun::star::chart::ChartAxisPosition CrossoverPosition; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Determines the scale value on the other axis when CrossoverPosition is set to VALUE. */ - [optional, property] double CrossoverValue; + [optional, property] double CrossoverValue; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Indicates the reference value where bars or areas have their grounding. - This property has only an effect when the used odf fileformat does not allow for - further axis posiioning or the axis is a secondary y-axis. + This property has only an effect when the used odf fileformat does not allow for + further axis positioning or the axis is a secondary y-axis. */ - [optional, property] double Origin; + [optional, property] double Origin; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** The origin is calculated by the chart if this property is <TRUE/>. - */ - [optional, property] boolean AutoOrigin; - - //------------------------------------------------------------------------- - /** Properties for interval marks: - */ - - //------------------------------------------------------------------------- - + */ + [optional, property] boolean AutoOrigin; + + //------------------------------------------------------------------------- + /** Properties for interval marks: + */ + + //------------------------------------------------------------------------- + /** Determines the type of the marks.@see ChartAxisMarks */ - [property] long Marks; - - //------------------------------------------------------------------------- - + [property] long Marks; + + //------------------------------------------------------------------------- + /** Determines the type of the help marks.@see ChartAxisMarks */ - [property] long HelpMarks; - //------------------------------------------------------------------------- - + [property] long HelpMarks; + //------------------------------------------------------------------------- + /** Determines where the interval marks are placed. */ - [optional, property] com::sun::star::chart::ChartAxisMarkPosition MarkPosition; + [optional, property] com::sun::star::chart::ChartAxisMarkPosition MarkPosition; - //------------------------------------------------------------------------- - /** Properties for axes labels: - */ + //------------------------------------------------------------------------- + /** Properties for axes labels: + */ + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Determines whether to display text at the axis or not. */ - [property] boolean DisplayLabels; + [property] boolean DisplayLabels; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Contains the type id for the number formatter of the axis. - @see com::sun::star::util::XNumberFormatter + @see com::sun::star::util::XNumberFormatter */ [property] long NumberFormat; //------------------------------------------------------------------------- - /** determines whether to use the number format given by the - container application, e.g. a spreadsheet document, or from - the own property <member>NumberFormat</member>. - */ - [optional, property] boolean LinkNumberFormatToSource; + /** determines whether to use the number format given by the + container application, e.g. a spreadsheet document, or from + the own property <member>NumberFormat</member>. + */ + [optional, property] boolean LinkNumberFormatToSource; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Determines where the axis labels are placed. */ - [optional, property] com::sun::star::chart::ChartAxisLabelPosition LabelPosition; - - //------------------------------------------------------------------------- - + [optional, property] com::sun::star::chart::ChartAxisLabelPosition LabelPosition; + + //------------------------------------------------------------------------- + /** Determines the rotation of the text elements (axis description) in 100th degrees. */ - [property] long TextRotation; + [property] long TextRotation; + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** The axis description may be arranged in a special order for a better placement. */ - [property] com::sun::star::chart::ChartAxisArrangeOrderType ArrangeOrder; - - //------------------------------------------------------------------------- - + [property] com::sun::star::chart::ChartAxisArrangeOrderType ArrangeOrder; + + //------------------------------------------------------------------------- + /** Determines if long text is broken into multiple lines. */ - [property] boolean TextBreak; + [property] boolean TextBreak; - //------------------------------------------------------------------------- + //------------------------------------------------------------------------- /** Determines if certain labels are hidden, if they would otherwise overlap. In this case, the value of this property must be set to <FALSE/>. */ [property] boolean TextCanOverlap; - //------------------------------------------------------------------------- - /** Properties related to bar charts: - */ + //------------------------------------------------------------------------- + /** Properties related to bar charts: + */ + + //------------------------------------------------------------------------- - //------------------------------------------------------------------------- - /** Determines the overlap of the bars in a bar-type chart. - + <p>The value is given in percent of the width of the bars. The valid range is -100% to +100%. +100% means full overlap, -100% indicates a distance of one bar between 2 neighboring bars.</p> */ - [property] long Overlap; - - //------------------------------------------------------------------------- - + [property] long Overlap; + + //------------------------------------------------------------------------- + /** Specifies the width of the gaps between each set of data points in a bar chart. - + <p>The value is given in percent of the width of a bar; the valid range is 0 to 600%.</p> */ - [property] long GapWidth; -}; - -//============================================================================= - -}; }; }; }; - + [property] long GapWidth; +}; + +//============================================================================= + +}; }; }; }; + #endif diff --git a/main/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java b/main/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java index 08a175f..c9e82d3 100644 --- a/main/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java +++ b/main/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,19 +7,20 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ + package mod._dbaccess; //import com.sun.star.awt.XControl; @@ -57,265 +58,265 @@ import com.sun.star.sdbc.XDataSource; public class OQueryDesign extends TestCase { - private static XDesktop xDesk; - private static XFrame xFrame; - private final String sDataSourceName = "Bibliography"; - private static XConnection xConn; - private static XTextDocument xTextDoc; - - - /** - * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). - */ - protected void initialize(TestParameters Param, PrintWriter log) { - xDesk = (XDesktop) UnoRuntime.queryInterface( - XDesktop.class, DesktopTools.createDesktop((XMultiServiceFactory)Param.getMSF()) ); - } - - protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { - - log.println( "creating a test environment" ); - - XInterface oObj = null; - - XDispatchProvider aProv = (XDispatchProvider) - UnoRuntime.queryInterface(XDispatchProvider.class,xDesk); - - XDispatch getting = null; - XMultiServiceFactory xMSF = (XMultiServiceFactory) Param.getMSF(); - - XNameAccess xNameAccess = null; - - // we use the first datasource - XDataSource xDS = null; - try { - xNameAccess = (XNameAccess) UnoRuntime.queryInterface( - XNameAccess.class, - xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); - } catch (Exception ex) { - ex.printStackTrace( log ); - throw new StatusException( "Could not get Databasecontext", ex ); - } - try { - xDS = (XDataSource) UnoRuntime.queryInterface( - XDataSource.class, xNameAccess.getByName( "Bibliography" )); - } catch (NoSuchElementException ex) { - ex.printStackTrace( log ); - throw new StatusException( "Could not get XDataSource", ex ); - } catch (WrappedTargetException ex) { - ex.printStackTrace( log ); - throw new StatusException( "Could not get XDataSource", ex ); - } - try { - xNameAccess = (XNameAccess) UnoRuntime.queryInterface( - XNameAccess.class, - xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); - } catch (Exception ex) { - ex.printStackTrace( log ); - throw new StatusException( "Could not get DatabaseConext", ex ); - } - - log.println("check XMultiServiceFactory"); - - try { - xConn = xDS.getConnection(new String(), new String()); - } catch (SQLException ex) { - ex.printStackTrace( log ); - throw new StatusException( "Could not get XConnection", ex ); - } - - log.println( "opening QueryDesign" ); - URL the_url = new URL(); - the_url.Complete = ".component:DB/QueryDesign"; - getting = aProv.queryDispatch(the_url,"Query",12); - PropertyValue[] Args = new PropertyValue[2]; - PropertyValue param1 = new PropertyValue(); - param1.Name = "DataSourceName"; - param1.Value = "Bibliography"; - Args[0] = param1; - PropertyValue param2 = new PropertyValue(); - param2.Name = "QueryDesignView"; - param2.Value = new Boolean(false); - Args[1] = param2; - param1.Name = "ActiveConnection"; - param1.Value = xConn; - Args[1] = param2; - getting.dispatch(the_url,Args); - - shortWait(); - - Object oDBC = null; - - try { - oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); - } - catch( com.sun.star.uno.Exception e ) { - throw new StatusException("Could not instantiate DatabaseContext", e) ; - } - - Object oDataSource = null; - try{ - XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBC); - oDataSource = xNA.getByName(sDataSourceName); - } catch ( com.sun.star.container.NoSuchElementException e){ - throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; - } catch ( com.sun.star.lang.WrappedTargetException e){ - throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; - } - XDocumentDataSource xDDS = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); -// XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); - -// Frame = xMod.getCurrentController().getFrame(); - - xFrame = DesktopTools.getCurrentFrame(xMSF); - - // get an instance of Frame - Object oFrame = null; - SOfficeFactory SOF = null; - - SOF = SOfficeFactory.getFactory( xMSF ); - try { - log.println( "creating a textdocument" ); - xTextDoc = SOF.createTextDoc( null ); - } catch ( com.sun.star.uno.Exception e ) { - e.printStackTrace( log ); - throw new StatusException( "Could not create document", e ); - } - - XModel xDocMod = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc); - - XFrame xTextFrame = xDocMod.getCurrentController().getFrame(); - - Object[] params = new Object[3]; - param1 = new PropertyValue(); - param1.Name = "DataSourceName"; - param1.Value = "Bibliography"; - params[0] = param1; - param2 = new PropertyValue(); - param2.Name = "Frame"; - param2.Value = xTextFrame; - params[1] = param2; - PropertyValue param3 = new PropertyValue(); - param3.Name = "QueryDesignView"; - param3.Value = new Boolean(true); - params[2] = param3; - - - oObj = xFrame.getController(); - - TestEnvironment tEnv = new TestEnvironment(oObj); - - //Adding ObjRelations for XInitialization - tEnv.addObjRelation("XInitialization.args", params); - - //Object[] ExceptionParams = new Object[3]; - //ExceptionParams = params; - //((PropertyValue) ExceptionParams[1]).Value = Frame; - Object[] ExceptionParams = new Object[3]; - PropertyValue ExceptionParam1 = new PropertyValue(); - ExceptionParam1.Name = "DataSourceName"; - ExceptionParam1.Value = "Bibliography2"; - ExceptionParams[0] = ExceptionParam1; - PropertyValue ExceptionParam2 = new PropertyValue(); - ExceptionParam2.Name = "Frame"; - ExceptionParam2.Value = null; - ExceptionParams[1] = ExceptionParam2; - PropertyValue ExceptionParam3 = new PropertyValue(); - ExceptionParam3.Name = "QueryDesignView"; - ExceptionParam3.Value = new Integer(17);//new Boolean(true); - ExceptionParams[2] = ExceptionParam3; - - tEnv.addObjRelation("XInitialization.ExceptionArgs", ExceptionParams); - - tEnv.addObjRelation("Frame", xFrame); - - tEnv.addObjRelation("XInitialization.xIni", getUnititializedObj(Param)); - - log.println("ImplementationName: "+util.utils.getImplName(oObj)); - - return tEnv; - - } // finish method getTestEnvironment - - private XInitialization getUnititializedObj(TestParameters Param){ - // creating an object wihch ist not initialized - - // get a model of a DataSource - Object oDBC = null; - XMultiServiceFactory xMSF; - - try { - xMSF = (XMultiServiceFactory)Param.getMSF(); - oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); - } - catch( com.sun.star.uno.Exception e ) { - throw new StatusException("Could not instantiate DatabaseContext", e) ; - } - - Object oDataSource = null; - try{ - XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBC); - oDataSource = xNA.getByName(sDataSourceName); - } catch ( com.sun.star.container.NoSuchElementException e){ - throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; - } catch ( com.sun.star.lang.WrappedTargetException e){ - throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; - } - - XDocumentDataSource xDDS = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); - XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); - - // get an intaces of QueryDesign - Object oQueryDesign = null; - try{ - oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign"); - }catch( com.sun.star.uno.Exception e ) { - throw new StatusException("Could not instantiate QueryDesign", e) ; - } - - XController xCont = (XController) UnoRuntime.queryInterface(XController.class, oQueryDesign); - - // marry them all - xCont.attachModel(xMod); - xMod.connectController(xCont); - try{ - xMod.setCurrentController(xCont); - } catch (com.sun.star.container.NoSuchElementException e){ - throw new StatusException("Could not set controller", e) ; - } - - //xCont.attachFrame(xFrame); - - return (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oQueryDesign); - - } - - @Override - protected void cleanup(TestParameters tParam, PrintWriter log) { - try { - xConn.close() ; - DesktopTools.closeDoc(xFrame); - DesktopTools.closeDoc(xTextDoc); - } catch (com.sun.star.uno.Exception e) { - log.println("Can't close the connection") ; - e.printStackTrace(log) ; - } catch (com.sun.star.lang.DisposedException e) { - log.println("Connection was already closed. It's OK.") ; - } - - } - - /** - * Sleeps for 0.2 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - try { - Thread.sleep(5000) ; - } catch (InterruptedException e) { - System.out.println("While waiting :" + e) ; - } - } - -} // finish class oDatasourceBrowser + private static XDesktop xDesk; + private static XFrame xFrame; + private final String sDataSourceName = "Bibliography"; + private static XConnection xConn; + private static XTextDocument xTextDoc; + + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + protected void initialize(TestParameters Param, PrintWriter log) { + xDesk = (XDesktop) UnoRuntime.queryInterface( + XDesktop.class, DesktopTools.createDesktop((XMultiServiceFactory)Param.getMSF()) ); + } + + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + log.println( "creating a test environment" ); + + XInterface oObj = null; + + XDispatchProvider aProv = (XDispatchProvider) + UnoRuntime.queryInterface(XDispatchProvider.class,xDesk); + + XDispatch getting = null; + XMultiServiceFactory xMSF = (XMultiServiceFactory) Param.getMSF(); + + XNameAccess xNameAccess = null; + + // we use the first DataSource + XDataSource xDS = null; + try { + xNameAccess = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + } catch (Exception ex) { + ex.printStackTrace( log ); + throw new StatusException( "Could not get Databasecontext", ex ); + } + try { + xDS = (XDataSource) UnoRuntime.queryInterface( + XDataSource.class, xNameAccess.getByName( "Bibliography" )); + } catch (NoSuchElementException ex) { + ex.printStackTrace( log ); + throw new StatusException( "Could not get XDataSource", ex ); + } catch (WrappedTargetException ex) { + ex.printStackTrace( log ); + throw new StatusException( "Could not get XDataSource", ex ); + } + try { + xNameAccess = (XNameAccess) UnoRuntime.queryInterface( + XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + } catch (Exception ex) { + ex.printStackTrace( log ); + throw new StatusException( "Could not get DatabaseConext", ex ); + } + + log.println("check XMultiServiceFactory"); + + try { + xConn = xDS.getConnection(new String(), new String()); + } catch (SQLException ex) { + ex.printStackTrace( log ); + throw new StatusException( "Could not get XConnection", ex ); + } + + log.println( "opening QueryDesign" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/QueryDesign"; + getting = aProv.queryDispatch(the_url,"Query",12); + PropertyValue[] Args = new PropertyValue[2]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + Args[0] = param1; + PropertyValue param2 = new PropertyValue(); + param2.Name = "QueryDesignView"; + param2.Value = new Boolean(false); + Args[1] = param2; + param1.Name = "ActiveConnection"; + param1.Value = xConn; + Args[1] = param2; + getting.dispatch(the_url,Args); + + shortWait(); + + Object oDBC = null; + + try { + oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + } + catch( com.sun.star.uno.Exception e ) { + throw new StatusException("Could not instantiate DatabaseContext", e) ; + } + + Object oDataSource = null; + try{ + XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + } catch ( com.sun.star.container.NoSuchElementException e){ + throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; + } catch ( com.sun.star.lang.WrappedTargetException e){ + throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; + } + XDocumentDataSource xDDS = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); +// XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); + +// Frame = xMod.getCurrentController().getFrame(); + + xFrame = DesktopTools.getCurrentFrame(xMSF); + + // get an instance of Frame + Object oFrame = null; + SOfficeFactory SOF = null; + + SOF = SOfficeFactory.getFactory( xMSF ); + try { + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace( log ); + throw new StatusException( "Could not create document", e ); + } + + XModel xDocMod = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XFrame xTextFrame = xDocMod.getCurrentController().getFrame(); + + Object[] params = new Object[3]; + param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + param2 = new PropertyValue(); + param2.Name = "Frame"; + param2.Value = xTextFrame; + params[1] = param2; + PropertyValue param3 = new PropertyValue(); + param3.Name = "QueryDesignView"; + param3.Value = new Boolean(true); + params[2] = param3; + + + oObj = xFrame.getController(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //Adding ObjRelations for XInitialization + tEnv.addObjRelation("XInitialization.args", params); + + //Object[] ExceptionParams = new Object[3]; + //ExceptionParams = params; + //((PropertyValue) ExceptionParams[1]).Value = Frame; + Object[] ExceptionParams = new Object[3]; + PropertyValue ExceptionParam1 = new PropertyValue(); + ExceptionParam1.Name = "DataSourceName"; + ExceptionParam1.Value = "Bibliography2"; + ExceptionParams[0] = ExceptionParam1; + PropertyValue ExceptionParam2 = new PropertyValue(); + ExceptionParam2.Name = "Frame"; + ExceptionParam2.Value = null; + ExceptionParams[1] = ExceptionParam2; + PropertyValue ExceptionParam3 = new PropertyValue(); + ExceptionParam3.Name = "QueryDesignView"; + ExceptionParam3.Value = new Integer(17); // new Boolean(true); + ExceptionParams[2] = ExceptionParam3; + + tEnv.addObjRelation("XInitialization.ExceptionArgs", ExceptionParams); + + tEnv.addObjRelation("Frame", xFrame); + + tEnv.addObjRelation("XInitialization.xIni", getUninitializedObj(Param)); + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + return tEnv; + + } // finish method getTestEnvironment + + private XInitialization getUninitializedObj(TestParameters Param){ + // create an object which is not initialized + + // get a model of a DataSource + Object oDBC = null; + XMultiServiceFactory xMSF; + + try { + xMSF = (XMultiServiceFactory)Param.getMSF(); + oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + } + catch( com.sun.star.uno.Exception e ) { + throw new StatusException("Could not instantiate DatabaseContext", e) ; + } + + Object oDataSource = null; + try{ + XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + } catch ( com.sun.star.container.NoSuchElementException e){ + throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; + } catch ( com.sun.star.lang.WrappedTargetException e){ + throw new StatusException("could not get '" + sDataSourceName + "'" , e) ; + } + + XDocumentDataSource xDDS = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); + XModel xMod = (XModel) UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); + + // get an instance of QueryDesign + Object oQueryDesign = null; + try{ + oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign"); + }catch( com.sun.star.uno.Exception e ) { + throw new StatusException("Could not instantiate QueryDesign", e) ; + } + + XController xCont = (XController) UnoRuntime.queryInterface(XController.class, oQueryDesign); + + // marry them all + xCont.attachModel(xMod); + xMod.connectController(xCont); + try{ + xMod.setCurrentController(xCont); + } catch (com.sun.star.container.NoSuchElementException e){ + throw new StatusException("Could not set controller", e) ; + } + + //xCont.attachFrame(xFrame); + + return (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oQueryDesign); + + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + try { + xConn.close() ; + DesktopTools.closeDoc(xFrame); + DesktopTools.closeDoc(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + log.println("Can't close the connection") ; + e.printStackTrace(log) ; + } catch (com.sun.star.lang.DisposedException e) { + log.println("Connection was already closed. It's OK.") ; + } + + } + + /** + * Sleeps for 0.2 sec. to allow OpenOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(5000) ; + } catch (InterruptedException e) { + System.out.println("While waiting :" + e) ; + } + } + +} // finish class oDatasourceBrowser diff --git a/main/qadevOOo/tests/java/mod/_forms/GenericModelTest.java b/main/qadevOOo/tests/java/mod/_forms/GenericModelTest.java index f85da93..7efa1b7 100644 --- a/main/qadevOOo/tests/java/mod/_forms/GenericModelTest.java +++ b/main/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -1,5 +1,5 @@ /************************************************************** - * + * * 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 @@ -7,19 +7,20 @@ * 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 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ + package mod._forms; import com.sun.star.beans.NamedValue; import com.sun.star.beans.PropertyValue; @@ -89,7 +90,7 @@ import util.utils; * {@link util.DBTools DBTools} class for more information.</li> * </ul> <p> * This object test <b> is NOT </b> designed to be run in several -* threads concurently. +* threads concurrently. * @see com.sun.star.io.XPersistObject * @see com.sun.star.awt.UnoControlDateFieldModel * @see com.sun.star.form.XReset @@ -134,31 +135,31 @@ public class GenericModelTest extends TestCase { private static Object m_dbSrc = null; private static DBTools.DataSourceInfo m_srcInf = null; /** - * This is the name of the Data Base which the test uses: "APITestDatabase" - */ + * This is the name of the Database which the test uses: "APITestDatabase" + */ protected final static String m_dbSourceName = "APITestDatabase"; protected final static String m_TestDB = "TestDB"; private DBTools m_dbTools = null; - + private static boolean m_ConnectionColsed = false; - + /** - * descibes the kind of the shape which should be created. + * describes the kind of the shape which should be created. * Example: m_kindOfshape=DateFiled - */ + */ public static String m_kindOfControl = null; - + /** - * If your object needs some special propery values you can specify them with this + * If your object needs some special property values you can specify them with this * <CODE>ArrayList</CODE>. You have to add a <CODE>NamedValue</CODE> to this list. * Example: * NamedValue myProp = new NamedValue(); * myProp.Name = "Test"; * myProp.Value = "My special Value"; * m_propertiesToSet.add(myProp); - */ + */ public static ArrayList m_propertiesToSet = new ArrayList(); - + /** * This variable contains the name of the property which should be changed while * interface <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> is tested. The @@ -166,7 +167,7 @@ public class GenericModelTest extends TestCase { * "XUpdateBroadcaster.Checker" which is a <CODE>ifc.form._XUpdateBroadcaster.UpdateChecker</CODE>. * @see ifc.form._XUpdateBroadcaster.UpdateChecker * @see ifc.form._XUpdateBroadcaster - */ + */ public static String m_ChangePropertyName = null; /** * This variable contains the value the property should be set while @@ -177,50 +178,50 @@ public class GenericModelTest extends TestCase { * the value of the property. If the current of this property is NULL the * <CODE>ValueChanger</CODE> is unable to change the value. In this case the value * of this variable was used. - */ + */ public static Object m_ChangePropertyValue = null; - + /** - * This variable contains the implelemtation name of the object. - */ + * This variable contains the implementation name of the object. + */ public static String m_ObjectName = null; - + /** - * For local implementaions of <CODE>Checker</CODE> this variable contains the + * For local implementations of <CODE>Checker</CODE> this variable contains the * <CODE>FormLoader</CODE> - */ + */ protected static XLoadable m_XFormLoader = null; /** - * For local implementaions of <CODE>Checker</CODE> this variable contains the + * For local implementations of <CODE>Checker</CODE> this variable contains the * <CODE>XPropertySet</CODE> - */ + */ protected static XPropertySet m_XPS = null; /** - * For local implementaions of <CODE>Checker</CODE> this variable contains the + * For local implementations of <CODE>Checker</CODE> this variable contains the * <CODE>Control</CODE> - */ + */ protected static XInterface m_XCtrl = null; /** - * The insterface test of <CODE>ifc.form._DataWareControlModel</CODE> expects an + * The interface test of <CODE>ifc.form._DataWareControlModel</CODE> expects an * object relation <CODE>'LC'</CODE>. This is a <CODE>XControlModel</CODE> of a shape. * This variable contains the kind of shape to create for the interface test, * f.e. "FixedText" * @see ifc.form._DataAwareControlModel */ protected static String m_LCShape_Type = null; - + protected static String m_XPropertyAccess_propertyToChange = "HelpText"; - + protected static String m_XPropertyContainer_propertyNotRemovable = "HelpText"; /** - * If this variable is true some more debug info was logged. It was set by the parameter variable + * If this variable is true some more debug info was logged. It was set by the parameter variable * <code>debug_is_active</code> */ protected static boolean debug = false; - + /** * Creates Writer document where controls are placed. - * @param tParam the test paremter + * @param tParam the test parameter * @param log the log writer */ protected void initialize(TestParameters tParam, PrintWriter log) { @@ -241,30 +242,30 @@ public class GenericModelTest extends TestCase { */ protected void cleanup(TestParameters tParam, PrintWriter log) { log.println("closing connection..."); - + // some interface tests call cleanup to reset the environment. If such // a test is the last one cleanup was called twice. The second call // causes then nasty exceptions... if (m_ConnectionColsed) return; - + try { XIndexAccess forms = UnoRuntime.queryInterface( XIndexAccess.class, FormTools.getForms( WriterTools.getDrawPage( m_xTextDoc ) ) ); - XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), + XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), forms.getByIndex(0)); - + if (debug){ if (myForm == null){ log.println("ERROR: could not get 'Standard' from drawpage!"); } - log.println("the draw page contains following elemtens:"); + log.println("the draw page contains following elements:"); String[] elements = FormTools.getForms(WriterTools.getDrawPage(m_xTextDoc)).getElementNames(); for (int i = 0; i< elements.length; i++){ log.println("Element[" + i + "] :" + elements[i]); } - + } - + XPropertySet xSetProp = UnoRuntime.queryInterface( XPropertySet.class, myForm ); XConnection connection = UnoRuntime.queryInterface( XConnection.class, xSetProp.getPropertyValue( "ActiveConnection" ) ); if ( connection == null ) @@ -304,7 +305,7 @@ public class GenericModelTest extends TestCase { } catch (Exception e) { log.println("ERROR: couldn't close data source: " + e.toString()); } - + log.println("disposing data source..."); try { XComponent dataSourceComp = (XComponent)UnoRuntime.queryInterface( @@ -314,7 +315,7 @@ public class GenericModelTest extends TestCase { catch (Exception e) { log.println("couldn't dispose the data source"); } - + log.println("closing document..."); try { @@ -336,7 +337,7 @@ public class GenericModelTest extends TestCase { } catch (com.sun.star.uno.Exception e) { log.println("ERROR: Error while object test cleaning up: " + e.toString()); } - + m_ConnectionColsed = true; } @@ -375,40 +376,40 @@ public class GenericModelTest extends TestCase { * @param log the log writer * @return a test environment */ - protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, + protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { XInterface oObj = null; XControlShape aShape = null; XMultiServiceFactory xMSF = (XMultiServiceFactory) Param.getMSF(); - + try{ - log.println("adding contol shape '" + m_kindOfControl + "'"); - aShape = FormTools.createControlShape(m_xTextDoc, 3000, - 4500, 15000, 10000, + log.println("adding control shape '" + m_kindOfControl + "'"); + aShape = FormTools.createControlShape(m_xTextDoc, 3000, + 4500, 15000, 10000, m_kindOfControl); } catch (Exception e){ e.printStackTrace(log); - throw new StatusException("Couldn't create following control shape (m_kindOfControl): '" + + throw new StatusException("Couldn't create following control shape (m_kindOfControl): '" + m_kindOfControl + "': ", e); - + } WriterTools.getDrawPage(m_xTextDoc).add((XShape) aShape); oObj = aShape.getControl(); - + log.println("Implementation name: " + util.utils.getImplName(oObj)); try { String sourceTestDB = utils.getFullURL(utils.getFullTestDocName("TestDB/testDB.dbf")); String destTestDB = utils.getOfficeTemp(xMSF); destTestDB = utils.getFullURL(destTestDB + "testDB.dbf"); - + log.println("copy '"+sourceTestDB + "' -> '" + destTestDB + "'"); utils.copyFile(xMSF, sourceTestDB, destTestDB); - + m_dbTools = new DBTools( xMSF, log ); String tmpDir = utils.getOfficeTemp((xMSF)); - + m_srcInf = m_dbTools.newDataSourceInfo(); m_srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); log.println("data source: " + m_srcInf.URL); @@ -416,7 +417,7 @@ public class GenericModelTest extends TestCase { m_dbSrc = m_srcInf.getDataSourceService(); m_dbTools.reRegisterDB(m_dbSourceName, m_dbSrc); - m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, + m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, m_TestDB); } catch (com.sun.star.uno.Exception e) { log.println("!!! Can't access TestDB !!!"); @@ -427,25 +428,25 @@ public class GenericModelTest extends TestCase { log.println("creating a new environment for object"); TestEnvironment tEnv = new TestEnvironment(oObj); - + tEnv.addObjRelation("OBJNAME", m_ObjectName); - + log.println("adding shape '" + m_LCShape_Type +"' for DataAwareControlModel test"); - aShape = FormTools.createControlShape(m_xTextDoc, 6000, 4500, 15000, + aShape = FormTools.createControlShape(m_xTextDoc, 6000, 4500, 15000, 10000, m_LCShape_Type); WriterTools.getDrawPage(m_xTextDoc).add((XShape) aShape); m_XPS = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, oObj); - + int i = 0; NamedValue prop = null; try { for (i = 0; i < m_propertiesToSet.size(); i++){ prop = (NamedValue) m_propertiesToSet.get(i); - + log.println("setting property: '"+prop.Name+"' to value '"+prop.Value.toString()+"'"); - + m_XPS.setPropertyValue(prop.Name, prop.Value); } } catch (com.sun.star.lang.WrappedTargetException e) { @@ -473,12 +474,12 @@ public class GenericModelTest extends TestCase { // adding relation for XUpdateBroadcaster m_XCtrl = oObj; - - tEnv.addObjRelation("XUpdateBroadcaster.Checker", + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); // adding relation for DataAwareControlModel service - tEnv.addObjRelation("DataAwareControlModel.NewFieldName", + tEnv.addObjRelation("DataAwareControlModel.NewFieldName", DBTools.TST_DATE_F); //adding ObjRelation for XPersistObject @@ -488,18 +489,18 @@ public class GenericModelTest extends TestCase { java.util.HashSet exclude = new java.util.HashSet(); exclude.add("FormatKey"); tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclude); - + PropertyValue propVal = new PropertyValue(); propVal.Name = m_XPropertyAccess_propertyToChange; propVal.Value = "Text since XPropertyAccess"; tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", m_XPropertyContainer_propertyNotRemovable); - + return tEnv; } // finish method getTestEnvironment - - + + static class Checker implements ifc.form._XUpdateBroadcaster.UpdateChecker { private Object lastValue = null; XLoadable formLoaderF = null; @@ -507,7 +508,7 @@ public class GenericModelTest extends TestCase { XInterface ctrl = null; String ChangePropertyName = null; Object ChangePropertyValue = null; - + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName, Object ChangePropertyValue) { formLoaderF = xl; this.ps = ps; @@ -515,26 +516,26 @@ public class GenericModelTest extends TestCase { this.ChangePropertyName=ChangePropertyName; this.ChangePropertyValue=ChangePropertyValue; } - + public void update() throws com.sun.star.uno.Exception { if (!formLoaderF.isLoaded()) { formLoaderF.load(); } lastValue = util.ValueChanger.changePValue(ps.getPropertyValue(ChangePropertyName)); - + if (lastValue == null){ if (ChangePropertyValue != null){ - + lastValue = ChangePropertyValue; - + } else { - + String msg = "The initial value of the property '" + ChangePropertyName + "' is NULL\n"; msg += "The member variable 'm_ChangePropertyValue' is NULL\n"; msg += "Could not change Property."; - + throw new StatusException(Status.failed(msg)); } } @@ -545,7 +546,7 @@ public class GenericModelTest extends TestCase { XBoundComponent bound = (XBoundComponent) UnoRuntime.queryInterface( XBoundComponent.class, ctrl); XResultSetUpdate update = (XResultSetUpdate) UnoRuntime.queryInterface( - XResultSetUpdate.class, + XResultSetUpdate.class, formLoaderF); bound.commit(); @@ -561,3 +562,4 @@ public class GenericModelTest extends TestCase { } } } // finish class GenericModelTest +