diff options
Diffstat (limited to 'testautomation/dbaccess/tools')
-rwxr-xr-x | testautomation/dbaccess/tools/controltools.inc | 831 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/dbcreatetools.inc | 1631 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/dbinit.inc | 56 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/dbtools.inc | 373 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/formtools.inc | 193 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/querytools.inc | 434 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/reporttools.inc | 387 | ||||
-rwxr-xr-x | testautomation/dbaccess/tools/tabletools.inc | 771 |
8 files changed, 4676 insertions, 0 deletions
diff --git a/testautomation/dbaccess/tools/controltools.inc b/testautomation/dbaccess/tools/controltools.inc new file mode 100755 index 000000000000..28b0583c0b42 --- /dev/null +++ b/testautomation/dbaccess/tools/controltools.inc @@ -0,0 +1,831 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Helper Routines for Form and Control Tests +'* +'*************************************************************************************** +'* +' #1 fSwitchAutopilotOff +' #1 fSetControlProperty +' #1 fGetControlProperty +' #1 hDrawingWithSelection +' #1 fOpenControlPropertyBrowser +' #1 addControl +' #1 fSwitchControlDesignMode +' #1 closePropertyBrowserAndDocument +' #1 fOpenMoreControlsToolBar +'* +'\************************************************************************************** + + +function fSwitchAutopilotOff(SwitchAutoOff as boolean) + '/// turn the Control autopilots off or on + '/// <u>parameter:</u> + '/// <b>SwitchAutoOff:</b> If true the autopilot is turned off, if the parameter is false the autopilot is turned on + + '/// open a new document + printlog "open a new document" + gApplication = "WRITER" + call hNewDocument + Kontext "DocumentWriter" + DocumentWriter.TypeKeys "tt_doc" , true + sleep(1) + Kontext "Toolbar" + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + '/// insert a group box to activate autopilot button + ListBox.Click + sleep(1) + call hDrawingWithSelection ( 50, 50, 60, 60 ) + sleep(2) + '/// check if auto pilot dialog is available + Kontext "AutoPilotListComboBox" + if AutoPilotListComboBox.Exists(3) then + Kontext "AutoPilotListComboBox" + AutoPilotListComboBox.Cancel + sleep(2) + if SwitchAutoOff = true then + Kontext "FormControls" + printlog "switch autopilot off" + UseWizards.Click + sleep(2) + else + printlog "let autopilot on" + endif + else + if SwitchAutoOff = false then + Kontext "FormControls" + printlog "switch autopilot on" + UseWizards.Click + sleep(2) + else + printlog "let autopilot off" + endif + endif + hCloseDocument +end function +'-------------------------------------------------------------------------------------- +function fSetControlProperty(sControlType, sPropertyName, sPropertyValue as string) + '/// set the property of a control via the control property browser + '/// <u>parameter:</u> + '/// <b>sControlType:</b> The name of the control type f.e. TextBox + '/// <b>sPropertyName:</b> The name of the control property f.e. DefaultValue + '/// <b>sPropertyValue:</b> The value of the control property + + ' switch to the General Page + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + + Kontext "TabGeneralControl" + if TabGeneralControl.exists(3) then + printlog "Set Property '" + sPropertyName + "' to the value '" + sPropertyValue + "' for a '" + sControlType + "' control." + ' A - C + + if sPropertyName = "Accuracy" then + Accuracy.setText(sPropertyValue) + elseif sPropertyName = "Align" then + Align.select(Cint(sPropertyValue)) + elseif sPropertyName = "AdditionalInfo" then + Information.setText(sPropertyValue) + Information.TypeKeys("<RETURN>",true) + elseif sPropertyName = "AutoComplete" then + AutoComplete.select(Cint(sPropertyValue)) + elseif sPropertyName = "Background" then + Background.select(Cint(sPropertyValue)) + elseif sPropertyName = "Border" then + Border.select(Cint(sPropertyValue)) + elseif sPropertyName = "BorderColor" then + BorderColor.select(Cint(sPropertyValue)) + elseif sPropertyName = "ButtonType" then + ButtonType.select(Cint(sPropertyValue)) + elseif sPropertyName = "BlockIncrement" then + BlockIncrement.setText(sPropertyValue) + elseif sPropertyName = "CellBound" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + CellBound.setText(sPropertyValue) + CellBound.typeKeys("<RETURN>",true) + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "CellRange" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + CellRange.setText(sPropertyValue) + CellRange.typeKeys("<RETURN>",true) + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "CurrSymPosition" then + CurrSymPosition.select(Cint(sPropertyValue)) + elseif sPropertyName = "CurrencySymbol" then + CurrencySymbol.setText(sPropertyValue) + + 'D - F + + elseif sPropertyName = "DateMax" then + DateMax.setText(sPropertyValue) + elseif sPropertyName = "DateMin" then + DateMin.setText(sPropertyValue) + elseif sPropertyName = "DateFormat" then + DateFormat.select(Cint(sPropertyValue)) + elseif sPropertyName = "DefaultButton" then + DefaultButton.select(Cint(sPropertyValue)) + elseif sPropertyName = "DefaultSelection2" then + DefaultSelection2.setText(sPropertyValue) + elseif sPropertyName = "DefaultState" then + DefaultState.select(Cint(sPropertyValue)) + elseif sPropertyName = "DefaultValue" then + TabGeneralControl.MouseDown 1,1,1,true + TabGeneralControl.MouseUp 1,1,1,true + sleep(1) + TabGeneralControl.TypeKeys "<TAB>" , 16 , true + sleep(1) + TabGeneralControl.TypeKeys sPropertyValue , true + sleep(1) + TabGeneralControl.TypeKeys "<RETURN>" , true + sleep(1) + elseif sPropertyName = "Delay" then + Delay.setText(sPropertyValue) + elseif sPropertyName = "DropDown" then + DropDown.select(Cint(sPropertyValue)) + elseif sPropertyName = "Enabled" then + Enabled.select(Cint(sPropertyValue)) + elseif sPropertyName = "EditMask" then + EditMask.setText(sPropertyValue) + elseif sPropertyName = "FilteringSorting" then + FilteringSorting.select(Cint(sPropertyValue)) + elseif sPropertyName = "Frame" then + Frame.select(Cint(sPropertyValue)) + + 'G - L + + elseif sPropertyName = "Graphics" then + Graphics.setText(sPropertyValue) + elseif sPropertyName = "GraphicsAlignment" then + GraphicsAlignment.select(Cint(sPropertyValue)) + elseif sPropertyName = "HelpText" then + HelpText.setText(sPropertyValue) + elseif sPropertyName = "HelpURL" then + HelpURL.setText(sPropertyValue) + HelpURL.TypeKeys "<RETURN>",true + elseif sPropertyName = "HiddenValue" then + HiddenValue.setText(sPropertyValue) + elseif sPropertyName = "HideSelection" then + HideSelection.select(Cint(sPropertyValue)) + elseif sPropertyName = "IconSize" then + IconSize.select(Cint(sPropertyValue)) + elseif sPropertyName = "LineCount" then + LineCount.setText(sPropertyValue) + elseif sPropertyName = "LineIncrement" then + LineIncrement.setText(sPropertyValue) + elseif sPropertyName = "LiteralMask" then + LiteralMask.setText(sPropertyValue) + elseif sPropertyName = "ListEntries" then + ListEntries.setText(sPropertyValue) + + 'M - O + + elseif sPropertyName = "MaxTextLen" then + MaxTextLen.setText(sPropertyValue) + elseif sPropertyName = "MultiLine" then + qaerrorlog "The Property MultiLine doesn't exists anymore." + qaerrorlog "Please use TextType instead. This property will be removed soon." + TextType.select(Cint(sPropertyValue)) + elseif sPropertyName = "MultiLine2" then + MultiLine.select(Cint(sPropertyValue)) + elseif sPropertyName = "Multiselection" then + Multiselection.select(Cint(sPropertyValue)) + elseif sPropertyName = "NameText" then + NameText.setText(sPropertyValue) + NameText.typeKeys("<RETURN>",true) + elseif sPropertyName = "Navigation" then + Navigation.select(Cint(sPropertyValue)) + elseif sPropertyName = "NavigationBar" then + NavigationBar.select(Cint(sPropertyValue)) + elseif sPropertyName = "Orientation" then + Orientation.select(Cint(sPropertyValue)) + elseif sPropertyName = "Order" then + Order.setText(sPropertyValue) + + 'P - R + + elseif sPropertyName = "Password" then + Password.setText(sPropertyValue) + elseif sPropertyName = "ReferenceValue" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + ReferenceValue.setText(sPropertyValue) + ReferenceValue.TypeKeys("<RETURN>",true) + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "Repeat" then + Repeat.select(Cint(sPropertyValue)) + elseif sPropertyName = "Printable" then + Printable.select(Cint(sPropertyValue)) + elseif sPropertyName = "Positioning" then + Positioning.select(Cint(sPropertyValue)) + elseif sPropertyName = "RecordActions" then + RecordActions.select(Cint(sPropertyValue)) + elseif sPropertyName = "RecordMarker" then + RecordMarker.select(Cint(sPropertyValue)) + elseif sPropertyName = "ReferenceValueOff" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + ReferenceValueOff.setText(sPropertyValue) + ReferenceValueOff.TypeKeys("<RETURN>",true) + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "Readonly" then + Readonly.select(Cint(sPropertyValue)) + elseif sPropertyName = "RowHeight" then + RowHeight.setText(sPropertyValue) + + 'S + + elseif sPropertyName = "Scale" then + Scale.select(Cint(sPropertyValue)) + elseif sPropertyName = "Spin" then + Spin.select(CInt(sPropertyValue)) + elseif sPropertyName = "StrictFormat" then + StrictFormat.select(CInt(sPropertyValue)) + elseif sPropertyName = "Scrollbars" then + Scrollbars.select(Cint(sPropertyValue)) + elseif sPropertyName = "SymbolColor" then + SymbolColor.select(Cint(sPropertyValue)) + elseif sPropertyName = "TextType" then + TextType.select(Cint(sPropertyValue)) + elseif sPropertyName = "ScrollValueMin" then + ScrollValueMin.setText(sPropertyValue) + elseif sPropertyName = "ScrollValueMax" then + ScrollValueMax.setText(sPropertyValue) + elseif sPropertyName = "ScrollValueDefault" then + ScrollValueDefault.setText(sPropertyValue) + + 'T - U + + elseif sPropertyName = "TabOrder" then + Order.setText(sPropertyValue) + TabGeneralControl.TypeKeys "<RETURN>",true + elseif sPropertyName = "TabStop" then + TabStop.select(Cint(sPropertyValue)) + elseif sPropertyName = "TakeFocus" then + TakeFocus.select(Cint(sPropertyValue)) + elseif sPropertyName = "TextType" then + TextType.select(Cint(sPropertyValue)) + elseif sPropertyName = "ThousandSeperator" then + ThousandSeperator.select(CInt(sPropertyValue)) + elseif sPropertyName = "TimeFormat" then + TimeFormat.select(Cint(sPropertyValue)) + elseif sPropertyName = "TimeMax" then + TimeMax.setText(sPropertyValue) + elseif sPropertyName = "TimeMin" then + TimeMin.setText(sPropertyValue) + elseif sPropertyName = "ToggleProp" then + ToggleProp.select(Cint(sPropertyValue)) + elseif sPropertyName = "TriState" then + TriState.select(Cint(sPropertyValue)) + elseif sPropertyName = "URL" then + URL.setText(sPropertyValue) + + 'V - Z + + elseif sPropertyName = "VisibleSize" then + VisibleSize.setText(sPropertyValue) + elseif sPropertyName = "ValueMin" then + if sControlType = "FormattedField" then + EffectiveMin.setText(sPropertyValue) + else + ValueMin.setText(sPropertyValue) + endif + elseif sPropertyName = "ValueMax" then + if sControltype = "FormattedField" then + EffectiveMax.setText(sPropertyValue) + else + ValueMax.setText(sPropertyValue) + endif + elseif sPropertyName = "ValueStep" then + ValueStep.setText(sPropertyValue) + ' + else + warnlog "The property " + sPropertyName + " doesn't exists in the function fSetControlProperty." + warnlog "Please add it to the function in dbaccess/tools/controltools.inc." + endif + + 'need additional return + sleep(1) + TabGeneralControl.TypeKeys "<RETURN>",true + else + warnlog "The control property browser doesn't exists." + endif + sleep(1) +end function +'-------------------------------------------------------------------------------------- +function fGetControlProperty(sControlType,sPropertyName) + '/// get the property of a control from the control property browser + '/// <u>parameter:</u> + '/// <b>sControlType:</b> The name of the control type f.e. TextBox + '/// <b>sPropertyName:</b> The name of the control property f.e. DefaultValue + + Dim sReturn as String + + ' switch to the General Page + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + + Kontext "TabGeneralControl" + if TabGeneralControl.exists(3) then + + ' A - C + + if sPropertyName = "Accuracy" then + sReturn = Accuracy.getSelIndex + elseif sPropertyName = "AdditionalInfo" then + sReturn = Information.getText + elseif sPropertyName = "Align" then + sReturn = Align.getSelIndex + elseif sPropertyName = "AutoComplete" then + sReturn = AutoComplete.getSelIndex + elseif sPropertyName = "Background" then + sReturn = Background.getSelIndex + elseif sPropertyName = "BlockIncrement" then + sReturn = BlockIncrement.getText + elseif sPropertyName = "Border" then + sReturn = Border.getSelIndex + elseif sPropertyName = "BorderColor" then + sReturn = BorderColor.getSelIndex + elseif sPropertyName = "ButtonType" then + sReturn = ButtonType.getSelIndex + elseif sPropertyName = "CellBound" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + sReturn = CellBound.getText() + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "CellRange" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + sReturn = CellRange.getText() + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "CurrSymPosition" then + sReturn = CurrSymPosition.getSelIndex + elseif sPropertyName = "CurrencySymbol" then + sReturn = CurrencySymbol.getText + + 'D - F + + elseif sPropertyName = "DateMax" then + sReturn = DateMax.getText + elseif sPropertyName = "DateMin" then + sReturn = DateMin.getText + elseif sPropertyName = "DateFormat" then + sReturn = DateFormat.getSelIndex + elseif sPropertyName = "DefaultButton" then + sReturn = DefaultButton.getSelIndex + elseif sPropertyName = "Delay" then + sReturn = Delay.getText + elseif sPropertyName = "DefaultState" then + sReturn = DefaultState.getSelIndex + elseif sPropertyName = "DefaultSelection2" then + sReturn = DefaultSelection2.getText + elseif sPropertyName = "DefaultValue" then + sReturn = DefaultValue.getText + elseif sPropertyName = "DropDown" then + sReturn = DropDown.getSelIndex + elseif sPropertyName = "EditMask" then + sReturn = EditMask.getText + elseif sPropertyName = "Enabled" then + sReturn = Enabled.getSelIndex + elseif sPropertyName = "FilteringSorting" then + sReturn = FilteringSorting.getSelIndex + elseif sPropertyName = "Formatkey" then + sReturn = Formatkey.getText + elseif sPropertyName = "Frame" then + sReturn = Frame.getSelIndex + + 'G - L + + elseif sPropertyName = "Graphics" then + sReturn = Graphics.getSelText + elseif sPropertyName = "GraphicsAlignment" then + sReturn = GraphicsAlignment.getSelIndex + elseif sPropertyName = "HelpText" then + sReturn = HelpText.getText + elseif sPropertyName = "HelpURL" then + sReturn = HelpURL.getText + elseif sPropertyName = "HiddenValue" then + sReturn = HiddenValue.getText + elseif sPropertyName = "HideSelection" then + sReturn = HideSelection.getSelIndex + elseif sPropertyName = "IconSize" then + sReturn = IconSize.getSelIndex + elseif sPropertyName = "LineCount" then + sReturn = LineCount.getText + elseif sPropertyName = "LineIncrement" then + sReturn = LineIncrement.getText + elseif sPropertyName = "LiteralMask" then + sReturn = LiteralMask.getText + elseif sPropertyName = "ListEntries" then + sReturn = ListEntries.getText + + 'M - O + + elseif sPropertyName = "MaxTextLen" then + sReturn = MaxTextLen.getText + elseif sPropertyName = "MultiLine" then + sReturn = MultiLine.getSelIndex + elseif sPropertyName = "MultiLine2" then + sReturn = MultiLine.getSelIndex + elseif sPropertyName = "Multiselection" then + sReturn = Multiselection.getSelIndex + elseif sPropertyName = "NameText" then + sReturn = NameText.getText + elseif sPropertyName = "Navigation" then + sReturn = Navigation.getSelIndex + elseif sPropertyName = "NavigationBar" then + sReturn = NavigationBar.getSelIndex + elseif sPropertyName = "Order" then + sReturn = Order.getText + elseif sPropertyName = "Orientation" then + sReturn = Orientation.getSelIndex + + 'P - R + + elseif sPropertyName = "Password" then + sReturn = Password.getText + elseif sPropertyName = "Positioning" then + sReturn = Positioning.getSelIndex + elseif sPropertyName = "Printable" then + sReturn = Printable.getSelIndex + elseif sPropertyName = "Readonly" then + sReturn = Readonly.getSelIndex + elseif sPropertyName = "RecordActions" then + sReturn = RecordActions.getSelIndex + elseif sPropertyName = "RecordMarker" then + sReturn = RecordMarker.getSelIndex + elseif sPropertyName = "ReferenceValue" then + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabDataControl + Kontext "TabDataControl" + sReturn = ReferenceValue.getText + Kontext "ControlPropertiesTabControl" + ControlPropertiesTabControl.setPage TabGeneralControl + elseif sPropertyName = "Repeat" then + sReturn = Repeat.getSelIndex + elseif sPropertyName = "RowHeight" then + sReturn = RowHeight.getText + + 'S + + elseif sPropertyName = "Scale" then + sReturn = Scale.getSelIndex + elseif sPropertyName = "Scrollbars" then + sReturn = Scrollbars.getSelIndex + elseif sPropertyName = "ScrollValueDefault" then + sReturn = ScrollValueDefault.getText + elseif sPropertyName = "ScrollValueMax" then + sReturn = ScrollValueMax.getText + elseif sPropertyName = "ScrollValueMin" then + sReturn = ScrollValueMin.getText + elseif sPropertyName = "Spin" then + sReturn = Spin.getSelIndex + elseif sPropertyName = "StrictFormat" then + sReturn = StrictFormat.getSelIndex + elseif sPropertyName = "SymbolColor" then + sReturn = SymbolColor.getSelIndex + + 'T - U + + elseif sPropertyName = "TabStop" then + sReturn = TabStop.getSelIndex + elseif sPropertyName = "TakeFocus" then + sReturn = TakeFocus.getSelIndex + elseif sPropertyName = "TextType" then + sReturn = TextType.getSelIndex + elseif sPropertyName = "ThousandSeperator" then + sReturn = ThousandSeperator.getSelIndex + elseif sPropertyName = "TimeFormat" then + sReturn = TimeFormat.getSelIndex + elseif sPropertyName = "TimeMax" then + sReturn = TimeMax.getText + elseif sPropertyName = "TimeMin" then + sReturn = TimeMin.getText + elseif sPropertyName = "ToggleProp" then + sReturn = ToggleProp.getSelIndex + elseif sPropertyName = "TriState" then + sReturn = TriState.getSelIndex + + 'V - Z + + elseif sPropertyName = "ValueMin" then + if sControlType = "FormattedField" then + sReturn = EffectiveMin.getText + else + sReturn = ValueMin.getText + endif + elseif sPropertyName = "ValueMax" then + if sControltype = "FormattedField" then + sReturn = EffectiveMax.getText + else + sReturn = ValueMax.getText + endif + elseif sPropertyName = "VisibleSize" then + sReturn = VisibleSize.getText + elseif sPropertyName = "ValueStep" then + sReturn = ValueStep.getText + + endif + else + warnlog "The control property browser doesn't exists." + endif + fGetControlProperty = sReturn +end function +'-------------------------------------------------------------------------------------- +sub hDrawingWithSelection ( iStartX, iStartY, iEndX, iEndY ) + '/// move the mouse with pressed mouse button + '/// <u>parameter:</u> + '/// <b>iStartX:</b> The x start coordinate + '/// <b>iStartY:</b> The y start coordinate + '/// <b>iEndX:</b> The x end coordinate + '/// <b>iEndY:</b> The x end coordinate + + select case gApplication + + case "CALC" : Kontext "DocumentCalc" + DocumentCalc.MouseDown ( iStartX, iStartY ) + DocumentCalc.MouseMove ( iEndX, iEndY ) + DocumentCalc.MouseUp ( iEndX, iEndY ) + + case "WRITER" : Kontext "DocumentWriter" + DocumentWriter.MouseDown ( iStartX, iStartY ) + DocumentWriter.MouseMove ( iEndX, iEndY ) + DocumentWriter.MouseUp ( iEndX, iEndY ) + + case "HTML": Kontext "DocumentWriterWeb" + DocumentWriterWeb.MouseDown ( iStartX, iStartY ) + DocumentWriterWeb.MouseMove ( iEndX, iEndY ) + DocumentWriterWeb.MouseUp ( iEndX, iEndY ) + + case "MASTERDOCUMENT" : Kontext "DocumentMasterDoc" + DocumentMasterDoc.MouseDown ( iStartX, iStartY ) + DocumentMasterDoc.MouseMove ( iEndX, iEndY ) + DocumentMasterDoc.MouseUp ( iEndX, iEndY ) + + case "IMPRESS" : Kontext "DocumentImpress" + DocumentImpress.MouseDown ( iStartX, iStartY ) + DocumentImpress.MouseMove ( iEndX, iEndY ) + DocumentImpress.MouseUp ( iEndX, iEndY ) + + case "DRAW" : Kontext "DocumentDraw" + DocumentDraw.MouseDown ( iStartX, iStartY ) + DocumentDraw.MouseMove ( iEndX, iEndY ) + DocumentDraw.MouseUp ( iEndX, iEndY ) + + end select +end sub +'-------------------------------------------------------------------------------------- +function fOpenControlPropertyBrowser + '/// open the Control Properties Dialog + '/// <u>parameter:</u> + '/// <u>return:</u> + sleep(2) + + call hToolbarSelect("FormControls",true) + + Kontext "FormControls" + ControlProperties.Click + Kontext "ControlPropertiesDialog" + + if ControlPropertiesDialog.exists(3) then + 'nothing + else + Kontext "FormControls" + ControlProperties.Click + endif + + sleep(2) + fOpenControlPropertyBrowser=true + +end function +'-------------------------------------------------------------------------------------- +function addControl(sControl as String, isx as integer , isy as integer , iex as integer , iey as integer) + '/// add the specified control and the specified position + '/// <u>parameter:</u> + '/// <b>sControl</b> the control name + '/// <b>isx</b> the start x coordinate + '/// <b>isy</b> the start y coordinate + '/// <b>iex</b> the end x coordinate + '/// <b>iey</b> the end y coordinate + '/// <u>return:</u> + + dim oControl as Object + + if sControl = "SpinButton" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + SpinButton.Click + + elseif sControl = "ScrollBar" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + Scrollbar.Click + + elseif sControl = "ImageButton" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + ImageButton.Click + + elseif sControl = "ImageControl" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + ImageControl.Click + + elseif sControl = "FileControl" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + FileControl.Click + + elseif sControl = "DateField" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + DateField.Click + + elseif sControl = "TimeField" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + TimeField.Click + + elseif sControl = "NumericField" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + Numericfield.Click + + elseif sControl = "CurrencyField" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + CurrencyField.Click + + elseif sControl = "PatternField" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + PatternField.Click + + elseif sControl = "GroupBox" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + GroupBox.Click + + elseif sControl = "Grid" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + Grid.Click + + elseif sControl = "NavigationBar" then + + call hToolbarSelect("MoreControls",true) + Kontext "MoreControls" + NavigationBar.Click + + elseif sControl = "Edit" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + Edit.Click + + elseif sControl = "Label" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + Label.Click + + elseif sControl = "CheckBox" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + CheckBox.Click + + elseif sControl = "FormattedField" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + FormattedField.Click + + elseif sControl = "PushButton" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + PushButton.Click + + elseif sControl = "ListBox" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + ListBox.Click + + elseif sControl = "ComboBox" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + ComboBox.Click + + elseif sControl = "RadioButton" then + + call hToolbarSelect("FormControls",true) + Kontext "FormControls" + RadioButton.Click + + else + warnlog "control " + sControl + " not found. add to addControl in control tools." + endif + sleep(1) + + call hDrawingWithSelection ( isx, isy, iex, iey ) + + sleep(2) + + Kontext "FormControls" + +end Function +'-------------------------------------------------------------------------------------- +function fSwitchControlDesignMode() + '/// switch the control design on or off + '/// <u>parameter:</u> + '/// <u>return:</u> + + Kontext "Toolbar" + call hToolbarSelect("FormControls",true) + sleep(1) + Kontext "FormControls" + SwitchControlDesignMode.Click + +end function +'-------------------------------------------------------------------------------------- +function closePropertyBrowserAndDocument + '/// close control property browser and the document + '/// only used in the Control_Serveral tests + '/// <u>parameter:</u> + '/// <u>return:</u> + + printlog "close control property browser" + Kontext "ControlPropertiesDialog" + ControlPropertiesDialog.close + '/// close document + printlog "close document" + hCloseDocument + +end function +'-------------------------------------------------------------------------------------- +function fOpenMoreControlsToolBar + '/// open the More Controls toolbar + '/// <u>parameter:</u> + '/// <u>return:</u> + Kontext "MoreControls" + if not MoreControls.exists(1) then + Kontext "FormControls" + MoreControls.Click + Kontext "MoreControls" + endif +End function diff --git a/testautomation/dbaccess/tools/dbcreatetools.inc b/testautomation/dbaccess/tools/dbcreatetools.inc new file mode 100755 index 000000000000..2658281f65be --- /dev/null +++ b/testautomation/dbaccess/tools/dbcreatetools.inc @@ -0,0 +1,1631 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Library with function for creating all possible databases +'* +'*************************************************************************************** +'* +' #1 fCreateMySQL_ODBC_Datasource +' #1 fCreateMySQL_JDBC_Datasource +' #1 fCreateAdabasDatasource +' #1 fCreateLocalAdabasDatasource +' #1 fCreateJDBCDatasource +' #1 fCreateODBCDatasource +' #1 fCreateDbaseDatasource +' #1 fCreateADODatasource +' #1 fCreateTextDatasource +' #1 fCreateSpreadsheetDatasource +' #1 fCreateLDAPAddressbookDatasource +' #1 fCreateEvolutionAddressbookDatasource +' #1 fCreateWindowsAddressbookDatasource +' #1 fCreateOutlookAddressbookDatasource +' #1 fCreateMozillaAddressbookDatasource +' #1 fRegisterDatabaseFile +' #1 fDeRegisterDatabaseFile +' #1 fSetJDBCDriverFiles +' #1 getIdForDatabaseType +'* +'\*********************************************************************************** + +private const VERBOSE = true + +function fCreateMySQL_ODBC_Datasource(sFileName, sOdbcDSN, sUser,optional sRegister) as boolean + '/// create a new MySQL database via ODBC file with the given filename + '///+ and the given URL + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b>sOdbcDSN:</b> the name of the odbc datasource + '/// <b>sUser:</b> the user for the connection + '/// <b>sPassword:</b> the password for the connection + '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered + dim bOK as boolean + bOK = FALSE + +' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select( hGetDatabaseDisplayName( "sdbc:mysql:odbc:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + MySQLODBC.Check + NextBtn.Click + + Kontext "DatabaseWizard" + + '/// add the URL + printlog "add the URL" + MySQLODBCDSName.setText "sdbc:mysql:odbc:" + sOdbcDSN + + Kontext "DatabaseWizard" + NextBtn.Click + + Kontext "DatabaseWizard" + '/// add the user name + printlog "add the user name" + UserName.setText sUser + + '/// check the password required checkbox + printlog "check the password required checkbox" + PasswordRequired.Check + + Kontext "DatabaseWizard" + NextBtn.Click + + Kontext "DatabaseWizard" + FinishBtn.Click + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + call fCloseDatabase(true) + + fCreateMySQL_ODBC_Datasource = bOK + +end function +'------------------------------------------------------------------------- +function fCreateMySQL_JDBC_Datasource(sFileName,sDatabaseName,sHost,sPort,sUser,optional sRegister) as boolean + '/// create a new MySQL database via JDBC file with the given filename + '///+ and the given URL + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sDatabaseName:</b> the name of the mysql database + '/// <b>sHost:</b> the host where the mysql database is running + '/// <b>sPort:</b> the port where the mysql database is running + '/// <b>sUser:</b> the user for the connection + '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered + dim bOK as boolean + bOK = FALSE + + dim sEntry as string + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + sEntry = hGetDatabaseDisplayName( "sdbc:mysql:jdbc:*" ) + 'cut off the (JDBC) string + sEntry = Mid( sEntry , 1, len(sEntry) - Instr(sEntry,"(") ) + printlog "entry = " + sEntry + DatabaseType.select( sEntry ) + sleep(1) + NextBtn.Click + sleep(1) + MySQLJDBC.Check + NextBtn.Click + sleep(1) + MySQLDatabaseName.setText(sDatabaseName) + MySQLHostName.setText(sHost) + MySQLPort.setText(sPort) + + NextBtn.Click + sleep(1) + + '/// add the user name + printlog "add the user name" + UserName.setText sUser + + '/// check the password required checkbox + printlog "check the password required checkbox" + PasswordRequired.Check + + NextBtn.Click + FinishBtn.Click + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateMySQL_JDBC_Datasource = bOK + + sleep(1) + + call fCloseDatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateAdabasDatasource(sFileName,sURL,sUser, optional sRegister) as boolean + '/// create a new adabas database file with the given filename + '///+ and the given URL + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the URL for the adabas database + '/// <b>sUser:</b> the user for connect + '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered + dim bOK as boolean + bOK = FALSE + + try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// insert the adabas database name + printlog "insert the adabas database name" + AdabasDBName.setText("sdbc:adabas:" + sURL) + sleep(1) + '/// click Next + printlog "click Next" + NextBtn.Click + sleep(1) + '/// insert the user + printlog "insert the user" + UserName.setText sUser + PasswordRequired.Check + sleep(1) + '/// click Next + printlog "click Next" + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + ' register the database + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + bOK = true + printlog "*** Succeed *** Data source was created" + + fCreateAdabasDatasource = bOK + + sleep(1) + call fCloseDatabase(true) + + catch + bOk = false + warnlog "*** Failed *** Data source was not created" + + endcatch + +end function +'------------------------------------------------------------------------- +function fCreateLocalAdabasDatasource(sFileName,sDatabaseName,sSuperUser,sSuperPassword, optional sRegister) as boolean + '/// create a new adabas database file with the given filename + '///+ and the given URL + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the URL for the adabas database + '/// <b>sUser:</b> the user for connect + '/// <b>sPassword:</b> the password for connect + '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered + dim bOK as boolean + bOK = FALSE + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + 'try + + '/// --- Create new Adabas data source --- + printlog "--- Create new adabas data source ---" + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:adabas:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + + + Kontext "DatabaseWizard" + AdabasBrowse.Click + sleep(1) + + Kontext "DataSourceSelection" + Create.Click + sleep(1) + + Kontext "CreateNewAdabasDatabase" + DatabaseName.setText sDatabaseName + Administrator.setText sSuperUser + AdminPasswordBtn.Click + sleep(1) + + + Kontext "PasswordDLG" + Password.setText sSuperPassword + PasswordConfirm.setText sSuperPassword + PasswordDLG.OK + + Kontext "CreateNewAdabasDatabase" + CreateNewAdabasDatabase.OK + sleep(10) + + Kontext "DataSourceSelection" + DataSourceSelection.OK + + Kontext "DatabaseWizard" + '/// click Next + printlog "click Next" + NextBtn.Click + sleep(1) + '/// click Next + printlog "click Next" + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + + sleep(2) + + ' register the database + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + bOK = true + printlog "*** Succeed *** Data source was created" + + 'catch + bOk = false + warnlog "*** Failed *** Data source was not created" + + 'endcatch + + fCreateLocalAdabasDatasource = bOK + + sleep(1) + call fCloseDatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateHSQLDatasource(sFileName, optional sRegister) as boolean + '/// create a new hsql database file with the given filename + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered + dim bOK as boolean + bOK = FALSE + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + + try + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(10) + + Kontext "DatabaseWizard" + CreateNewDatabase.Check + sleep(1) + NextBtn.Click + sleep(1) + FinishBtn.Click + sleep(1) + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(10) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(5) + + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + call fCloseDatabase(true) + + bOK = true + catch + bOK = false + endcatch + + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateHSQLDatasource = bOK + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCreateJDBCDatasource(sFileName,sDriverClass,sURL,sClassPath,sUserName, optional sRegister) as boolean + 'TODO: + + 'ExitRestartTheOffice ' because the change the classpath wich is only used after a restart + 'Printlog "restart the office to make the classpath work" + + '/// create a new JDBC database file with the given filename + '///+ and the given URL + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b>sDatabaseName:</b> the name of the mysql database + '/// <b>sHost:</b> the host where the mysql database is running + '/// <b>sPort:</b> the port where the mysql database is running + '/// <b>sUser:</b> the user for the connection + '/// <b><i>optional</i> sRegister:</b> the name under which the database is be registered + dim bOK as boolean + bOK = FALSE + + call fSetJDBCDriverFiles(sClassPath) + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + FileOpen "FileName", "private:factory/sdatabase?Interactive" , "FrameName", "_blank" , "SynchronMode" ,True + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(5) + + Kontext "TabGeneral" + DatabaseType.Select "JDBC" + sleep(1) + + Kontext "ConnectionType" + NextBtn.Click + + Kontext "TabConnection" + + '/// add the URL + printlog "add the URL" + ConnectURL.setText "jdbc:" + sURL + + '/// add the user name + printlog "add the user name" + UserName.setText sUserName + + '/// check the password required checkbox + printlog "check the password required checkbox" + PasswordRequired.Check + + JDBCDriverClass.setText sDriverClass + + + Kontext "ConnectionType" + CreateBtn.Click + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(ConvertPath(sFilename),sRegister) + end if + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateJDBCDatasource = bOK + + sleep(1) + + call fCloseDatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateODBCDatasource(sDSName,sUser,sPassword) as boolean + + qaerrorlog "not implemented yet" + fCreateODBCDatasource = false + +end function +'------------------------------------------------------------------------- +function fCreateDbaseDatasource(sFileName,sURL, optional sRegister) as boolean + '/// create a new dbase database file with the given filename + '///+ and the given URL as dbase path + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the dbase path for the database + '/// <b><i>optional</i> bRegister:</b> if true the register the database with the name tt_dBase + dim bOK as boolean + bOK = FALSE + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:dbase:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + dBasePath.setText "sdbc:dbase:" + ConvertPath(sURL) + sleep(1) + FinishBtn.Click + + sleep(1) + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + bOK = true + 'if bOK = true then + ' printlog "--- End of function - *** Succeed ***"' + 'else + ' warnlog "--- End of function - *** Failed *** Data source was not created" + 'endif + + fCreatedBaseDatasource = bOK + + sleep(1) + + call fClosedatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateADODatasource(sFileName,sURL,optional sRegister) as boolean + '/// create a new ADO database file with the given filename + '///+ and the given URL as dbase path + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the ADO url + '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name + dim bOK as boolean + bOK = FALSE + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:ado:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// add the URL + printlog "add the URL " + sURL + AdoURL.setText "sdbc:ado:" + sURL + sleep(1) + FinishBtn.Click + sleep(1) + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateADODatasource = bOK + + sleep(1) + + call fClosedatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateTextDatasource(sFileName,sURL, optional sRegister) as boolean + '/// create a new text database file with the given filename + '///+ and the given URL as dbase path + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the Text url + '/// <b><i>optional</i> sRegister:</b> if set, the database is registed under the given name + Dim bOK as boolean + bOK = false + + '/// --- Create new Text data source --- + printlog "--- Create new " + sFileName + " data source ---" + printlog "--- with the URL " + sURL + " ---" + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:flat:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + TextPath.setText "sdbc:flat:" + ConvertPath(sURL) + sleep(1) + FinishBtn.Click + sleep(1) + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateTextDatasource = bOK + + sleep(1) + + call fClosedatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateSpreadsheetDatasource(sFileName,sURL, optional sRegister) as boolean + '/// create a new spreadsheet database file with the given filename + '///+ and the given URL as dbase path + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sURL:</b> the spreadsheet file name + '/// <b><i>optional</i> bRegister:</b> if true the register the database with the given name + dim bOK as boolean + bOK = FALSE + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.Select (hGetDatabaseDisplayName( "sdbc:calc:*" )) + sleep(1) + NextBtn.Click + sleep(1) + '/// add the URL + printlog "add the URL" + SpreadsheetPath.setText "sdbc:calc:" + ConvertPath(sURL) + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + bOK = true + if bOK = true then + printlog "--- End of function - *** Succeed ***" + else + warnlog "--- End of function - *** Failed *** Data source was not created" + endif + + fCreateSpreadsheetDatasource = bOK + + sleep(1) + + call fClosedatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateLDAPAddressbookDatasource(sFileName,sHostName,sBaseDN,sPortNr,optional sRegister) as boolean + '/// create a new LDAP Addressbook database with the given filename + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> if true then register the database + dim bOK as boolean + bOK = FALSE +' try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:ldap:*" ) ) + sleep(1) + NextBtn.Click + sleep(1) + LDAPHostName.setText sHostName + sleep(1) + BaseDN.setText(sBaseDN) + sleep(1) + FinishBtn.Click + sleep(1) + + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + + sleep(5) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + printlog "*** Succeed *** Data source was created" + bOK = true +' catch +' warnlog "*** Failed *** Data source was not created" +' bOK = false +' endcatch + + fCreateLDAPAddressbookDatasource = bOK + + sleep(1) + + call fClosedatabase(true) + +end function +'------------------------------------------------------------------------- +function fCreateEvolutionAddressbookDatasource(sFileName, optional sRegister) as boolean + '/// create a new Evolution Addressbook database with the given filename + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> if true then register the database + dim bOK as boolean + bOK = FALSE + try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:evolution:ldap" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + call fClosedatabase(true) + + printlog "*** Succeed *** Data source was created" + bOK = true + catch + warnlog "*** Failed *** Data source was not created" + bOK = false + endcatch + + fCreateEvolutionAddressbookDatasource = bOK + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCreateKDEAddressbookDatasource(sFileName , optional sRegister) as boolean + '/// create a new KDE Addressbook database with the given filename + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> if true then register the database + dim bOK as boolean + bOK = FALSE + try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:kab" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + call fClosedatabase(true) + + printlog "*** Succeed *** Data source was created" + bOK = true + catch + warnlog "*** Failed *** Data source was not created" + bOK = false + endcatch + + fCreateKDEAddressbookDatasource = bOK + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCreateWindowsAddressbookDatasource(sFileName , optional sRegister) as boolean + '/// create a new Windows Addressbook database with the given filename + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> if true then register the database + dim bOK as boolean + bOK = FALSE + try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlookexp" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + call fClosedatabase(true) + + printlog "*** Succeed *** Data source was created" + bOK = true + catch + warnlog "*** Failed *** Data source was not created" + bOK = false + endcatch + + fCreateWindowsAddressbookDatasource = bOK + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCreateOutlookAddressbookDatasource(sFileName, optional sRegister) as boolean + '/// create a new Outlook Addressbook database with the given filename + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> if true then register the database + dim bOK as boolean + bOK = FALSE + try + + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:outlook" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + + call fClosedatabase(true) + + printlog "*** Succeed *** Data source was created" + bOK = true + catch + warnlog "*** Failed *** Data source was not created" + bOK = false + endcatch + + fCreateOutlookAddressbookDatasource = bOK + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCreateMozillaAddressbookDatasource(sFileName, optional sRegister) as boolean + '/// create a new mozilla addressbook database file with the given filename + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b><i>optional</i> sRegister:</b> the name under which the database is registered + + dim bOK as boolean + bOK = FALSE + try + ' delete the file + if ( app.Dir( ConvertPath(sFileName) ) ) <> "" then + app.kill(ConvertPath(sFileName)) + endif + + Kontext "DocumentWriter" + if (DocumentWriter.exists(1)) then + DocumentWriter.UseMenu + else + Kontext "DocumentBackground" + DocumentBackground.UseMenu + endif + hMenuSelectNr(1) + hMenuSelectNr(1) + hMenuSelectNr(5) + + sleep(4) + + Kontext "DatabaseWizard" + ConnectToDatabase.Check + sleep(1) + DatabaseType.select ( hGetDatabaseDisplayName( "sdbc:address:mozilla:" ) ) + sleep(1) + NextBtn.Click + sleep(1) + '/// click finish + printlog "click finish" + FinishBtn.Click + sleep(1) + Kontext "SpeichernDlg" + Dateiname.setText ConvertPath(sFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(2) + + if ( IsMissing(sRegister) ) then + printlog "don't register datasource" + else + printlog "register datasource with name " + sRegister + call fRegisterDatabaseFile(sFileName,sRegister) + end if + printlog "*** Succeed *** Data source was created" + bOK = true + + call fClosedatabase(true) + + catch + qaerrorlog "*** Failed *** Data source was not created" + bOK = false + endcatch + + fCreateMozillaAddressbookDatasource = bOK + + sleep(1) + +end function +'-------------------------------------------------------------------- +function fRegisterDatabaseFile( sFileName, sName) + '/// register a database + '/// <u>parameter:</u> + '/// <b>sFielName:</b> the file name for the database file + '/// <b>sName:</b> The name under which the database is registered + + dim i as integer + + ToolsOptions + + call hToolsOptions ( "Datasources", "Databases" ) + + '/// remove registration if exists + + Kontext "TabRegisteredDatabase" + for i = 1 to RegisteredDatabases.GetItemCount + RegisteredDatabases.select i + if RegisteredDatabases.getSeltext() = sName then + DeleteBtn.Click + Kontext "Active" + Active.yes + exit for + endif + next + + + + Kontext "TabRegisteredDatabase" + NewBtn.Click + sleep(1) + Kontext "CreateDatabaseLink" + DatabaseFile.setText(sFileName) + RegisteredName.setText(sName) + CreateDatabaseLink.OK + + sleep(1) + Kontext "OptionenDlg" + OptionenDlg.OK + +end function +'-------------------------------------------------------------------- +function fDeRegisterDatabaseFile( sName) + '/// deregister a database + '/// <u>parameter:</u> + '/// <b>sName:</b> The registered name which should be deregistered + dim i as integer + + ToolsOptions + + call hToolsOptions ( "Datasources", "Databases" ) + + '/// remove registration for the database + printlog "remove registration for the database " + sName + + Kontext "TabRegisteredDatabase" + for i = 1 to RegisteredDatabases.GetItemCount + RegisteredDatabases.select i + if RegisteredDatabases.getSeltext() = sName then + DeleteBtn.Click + exit for + endif + next + + try + Kontext "Active" + Active.yes + catch + + endcatch + sleep(1) + Kontext "OptionenDlg" + OptionenDlg.OK + +end function +'------------------------------------------------------------------------- +function fSetJDBCDriverFiles(sClassPath) as boolean + '/// set the java classpath + '/// <u>parameter:</u> + '/// <b>sClassPath:</b> The Classpath + + Dim x_DriverInstall as boolean + x_DriverInstall = FALSE + + call hNewDocument + printlog "insert classpath: " + sClassPath + ToolsOptions + call hToolsOptions ( "StarOffice", "JAVA" ) + + Kontext "TabJava" + ClassPath.Click + sleep(1) + Kontext "JavaClassPath" + AddArchive.Click + sleep(1) + Kontext "GeneralFileDialog" + Dateiname.setText ConvertPath(sClassPath) + Auswaehlen.Click + sleep(1) + '/// if the class file allready exists a messages box pops up + Kontext "MessageBox" + if ( MessageBox.exists(3) ) then + MessageBox.OK + end if + + Kontext "JavaClassPath" + JavaClassPath.OK + + Kontext "MessageBox" + if ( MessageBox.exists(3) ) then + MessageBox.OK + end if + + Kontext "OptionenDlg" + OptionenDlg.OK + + call hCloseDocument + +end function + +'------------------------------------------------------------------------- + +function hGetInstalledDatabaseDrivers( dbDriverList() as string ) as integer + + ' This function returns the number of currently installed database drivers. + ' Additionally it fills a given list (which should be large enough to hold + ' the names of all installed drivers) with the url and makes the list + ' compatible to the listfunctions (which places the list size in element 0) + ' The list is platform dependent and might be locale dependent + ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up + ' in the Database Wizards listbox! + + dim oUnoOfficeConnection as object + dim oUnoConfigurationAccess as object + dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue + dim xViewRoot as object + dim aElements() as string + dim iCurrentDriver as integer + dim iDriverCount as integer + + const CFN = "dbaccess::tools::dbcreatetools.inc::hGetInstalledDatabaseDrivers(): " + + ' Path to the node, searches all files below "Drivers" for "Installed" + aPropertyValue( 0 ).Name = "nodepath" + aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed" + + ' Connect to remote UNO + oUnoOfficeConnection = hGetUnoService( TRUE ) + + if ( isNull( oUnoOfficeConnection )) then + warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" ) + hGetInstalledDatabaseDrivers() = 0 + else + ' Get a configuration provider + oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" ) + + ' Get access + xViewRoot = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() ) + aElements() = xViewRoot.getElementNames() + + iDriverCount = ubound( aElements() ) + dbDriverList( 0 ) = iDriverCount + for iCurrentDriver = 1 to iDriverCount + dbDriverList( iCurrentDriver ) = aElements( iCurrentDriver ) + next iCurrentDriver + + endif + + if ( GVERBOSE ) then + printlog( CFN & "Returning " & iDriverCount & " drivers" ) + endif + + hGetInstalledDatabaseDrivers() = iDriverCount + +end function + +'------------------------------------------------------------------------- + +function hGetDatabaseDisplayName( dbDriverURL as string ) as string + + ' The xcu files (based on dev300m47) hold following driver definitions + ' which are used as parameter to this function. You get a plain text + ' localized driver name as returnvalue which can be used directly to select + ' a driver in the Database Wizard. + + ' adabas.xcu: "sdbc:adabas:*" + ' calc.xcu: "sdbc:calc:*" + ' dbase.xcu: "sdbc:dbase:*" + ' evoab.xcu: "sdbc:address:evolution:ldap" + ' evoab.xcu: "sdbc:address:evolution:groupwise" + ' flat.xcu: "sdbc:flat:*" + ' ado.xcu: "sdbc:ado:*" + ' hsqldb.xcu: "sdbc:embedded:hsqldb" + ' kab.xcu: "sdbc:address:kab" + ' mozab.xcu: "sdbc:address:outlook" + ' mozab.xcu: "sdbc:address:outlookexp" + ' mozab.xcu: "sdbc:address:mozilla:" + ' mozab.xcu: "sdbc:address:thunderbird:" + ' mozab.xcu: "sdbc:address:ldap:*" + ' mysql.xcu: "sdbc:mysql:jdbc:*" + ' mysql.xcu: "sdbc:mysql:odbc:*" + ' odbc.xcu: "sdbc:odbc:*" + ' jdbc.xcu: "jdbc:*" + ' jdbc.xcu: "jdbc:oracle:thin:*" + ' mysql.xcu: "sdbc:mysql:jdbc:*" + + + ' Note that some drivers (like e.g. HSQL Database Engine) do *not* show up + ' in the Database Wizards listbox! + + + dim oUnoOfficeConnection as object + dim oUnoConfigurationAccess as object + dim aPropertyValue(1) as new com.sun.star.beans.PropertyValue + dim oConfig as object + dim oDriver as object + dim sDatabaseName as string + + const CFN = "dbaccess::tools::dbcreatetools.inc::hGetDatabaseDisplayName(): " + + ' Path to the node, searches all files below "Drivers" for "Installed" + aPropertyValue( 0 ).Name = "nodepath" + aPropertyValue( 0 ).Value = "org.openoffice.Office.DataAccess.Drivers/Installed/" + + ' Connect to remote UNO + oUnoOfficeConnection = hGetUnoService( TRUE ) + + if ( isNull( oUnoOfficeConnection )) then + warnlog( CFN & "Failed to establish UNO connection, hGetUnoService failed" ) + sDatabaseName = "" + else + ' Get a configuration provider + oUnoConfigurationAccess = oUnoOfficeConnection.createInstance( "com.sun.star.configuration.ConfigurationProvider" ) + + ' Get access + oConfig = oUnoConfigurationAccess.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aPropertyValue() ) + try + oDriver = oConfig.getByName( dbDriverURL ) + sDatabaseName = oDriver.getByName( "DriverTypeDisplayName" ) + catch + warnlog( CFN & "Invalid driver or driver unsupported on this platform" ) + sDatabaseName "" + endcatch + + endif + + if ( GVERBOSE ) then + printlog( CFN & "Database display string: " & sDatabaseName ) + endif + hGetDataBaseDisplayName() = sDatabaseName + +end function +'------------------------------------------------------------------------- +function isDriverInstalled( dbDriverURL as string ) as string + + ' This function return true or false if a driver for a given URL is installed + + Dim myDriverList(20) as string + Dim i as integer + Dim sDriver as string + Dim breturn as boolean + breturn = false + + const CFN = "dbaccess::tools::dbcreatetools.inc::isDriverInstalled(): " + + if VERBOSE then + printlog CFN + printlog "url to search for : " + dbDriverURL + endif + + hGetInstalledDatabaseDrivers( myDriverList() ) + + for i = 1 to ubound(myDriverList) + sDriver = myDriverList(i) + if VERBOSE then + printlog "found url : " + sDriver + endif + if sDriver = dbDriverURL then + breturn = true + endif + next + + isDriverInstalled = breturn + +end function + diff --git a/testautomation/dbaccess/tools/dbinit.inc b/testautomation/dbaccess/tools/dbinit.inc new file mode 100755 index 000000000000..53f192747926 --- /dev/null +++ b/testautomation/dbaccess/tools/dbinit.inc @@ -0,0 +1,56 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Helper Routines for Base tests. +'* +'*************************************************************************************** +'* +' #1 null +'* +'\*********************************************************************************** + +Global gDatasourceName as String +Global gTableName as String +'-------------------------------------------------------------------- +sub sDBInit + + 'global + use "global\system\includes\master.inc" + use "global\system\includes\gvariabl.inc" + + 'base + use "dbaccess\tools\formtools.inc" + use "dbaccess\tools\reporttools.inc" + use "dbaccess\tools\tabletools.inc" + use "dbaccess\tools\dbcreatetools.inc" + use "dbaccess\tools\querytools.inc" + use "dbaccess\tools\dbtools.inc" + use "dbaccess\tools\controltools.inc" + +end sub diff --git a/testautomation/dbaccess/tools/dbtools.inc b/testautomation/dbaccess/tools/dbtools.inc new file mode 100755 index 000000000000..2e40a3f25726 --- /dev/null +++ b/testautomation/dbaccess/tools/dbtools.inc @@ -0,0 +1,373 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Helper Routines for Base tests. +'* +'*************************************************************************************** +'* +' #1 fSelectDatasourceInBeamer +' #1 fConnectToDatasourceInBeamer +' #1 fSelectSchemaInTableFilter +' #1 fOpenNewDataBase +' #1 fOpenDataBase +' #1 fCloseDatabase +' #1 tools_dbtools_fgetMySQLDatabaseProperties +'* +'\*********************************************************************************** + +private const VERBOSE = true + +'-------------------------------------------------------------------- +function fSelectDatasourceInBeamer(sDSName1) + '/// select a datasource in the beamer with the given name + '/// <u>parameter:</u> + '/// <b>sDSName1:</b> the name of the datasource which shall be seleced + + dim i as integer + dim bfindDS as boolean + dim iNoDS as integer + + bfindDS = false + Kontext "DatabaseBeamer" + Kontext "DatabaseSelection" + + iNoDS = DatabaseSelection.getItemCount + for i = 1 to iNoDS + DatabaseSelection.Select i + if DatabaseSelection.getText = sDSName1 then + i = iNoDS + bfindDS = TRUE + endif + next i + + fSelectDatasourceInBeamer = bfindDS + + sleep(1) + +end function +'-------------------------------------------------------------------- +function fConnectToDatasourceInBeamer(sDSName , sPWD, optional bNewDoc) + + if ( isMissing (bNewDoc) )then + bNewDoc = false + endif + + if (bNewDoc) then + call hNewDocument() + ViewCurrentDatabase + endif + + sleep(1) + dim bConnect as boolean + bConnect = false + if fFindDatasource(sDSName) = true then + DatabaseSelection.TypeKeys "<ADD>" + DatabaseSelection.TypeKeys "<DOWN>" + DatabaseSelection.TypeKeys "<DOWN>" + DatabaseSelection.TypeKeys "<DOWN>" + DatabaseSelection.TypeKeys "<ADD>" + Kontext "LoginDialog" + if LoginDialog.Exists(3) then + LoginPassword.SetText sPWD + LoginDialog.OK + end if + bConnect = true + else + warnlog "Could not found the datasource " + sDSName + endif + + if (bNewDoc) then + call hCloseDocument + endif + + fConnectToDatasource = bConnect + +end function +'-------------------------------------------------------------------- +function fSelectSchemaInTableFilter(sSchema as String) + '/// select the given schema in the table filter dialog in an open database + '/// <u>parameter:</u> + '/// <b>sSchema:</b> the name of the schema + dim bOK as boolean + bOK = false + + dim iRem as integer + iRem = 0 + Kontext "DATABASE" + Database.useMenu + hMenuSelectNr 5 + hMenuSelectNr 3 + + + Kontext "TablesFilter" + printlog Tables.getItemCount + TablesFilter.OK + + fSelectSchemaInTableFilter = true + +end function +'------------------------------------------------------------------------- +function fOpenNewDataBase ( sSaveFileName ) + '/// open a database window and sabe it to the given name + '/// <u>parameter:</u> + '/// <b>sSaveFileName:</b> the file name for the database file + FileOpen "FileName", "private:factory/sdatabase" , "FrameName", "_blank" , "SynchronMode" ,True + + sleep(2) + + Kontext "SpeichernDlg" + Dateiname.setText Convertpath(gOfficePath + "/user/work/" + sSaveFileName) + Speichern.click + sleep(1) + + Kontext "MessageBox" + if MessageBox.exists then + MessageBox.yes + end if + + sleep(5) + +end function +'------------------------------------------------------------------------- +function fOpenDataBase ( sFileName , optional sPassword) + '/// open a database file with the given name and try to connect + '/// <u>parameter:</u> + '/// <b>sFileName:</b> the file name which shall be open + '/// <b><i>optional</i>sFileName:</b> the password for connecting + + Dim bOK as boolean + bOK = true + + Dim DieDatei as String + DieDatei = ConvertPath ( sFileName ) + + if(VERBOSE) then + printlog "Filename : " + sFileName + if(NOT isMissing(sPassword)) then + printlog "Password : " + sPassword + endif + endif + + '/// open the File Open dialog + printlog "open the File Open dialog" + FileOpen + sleep (1) + Kontext "OeffnenDlg" + '/// open the given file + Dateiname.SetText DieDatei + sleep (3) + Oeffnen.Click + sleep (3) + + 'click on the main window to get the focus + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + ViewTables + sleep(1) + + Kontext "DATABASE" + '/// if the password is given add the password + if ( Not IsMissing(sPassword) ) then + printlog "set password : " + sPassword + Kontext "LoginDialog" + if LoginDialog.Exists then + LoginPassword.setText sPassword + LoginDialog.OK + sleep(1) + endif + endif + Kontext "MessageBox" + if (MessageBox.exists(2)) then + 'an error occurr + bOK = false + dim iNrTexts as integer + Dim i as integer + iNrtexts = MessageBox.getFixedtextCount + for i = 1 to iNrtexts + qaerrorlog MessageBox.getFixedtext(i) + next + MessageBox.OK + ' try again to close the dialog if exists + if (MessageBox.exists(2)) then + MessageBox.OK + endif + call fCloseDatabase + endif + + fOpenDataBase = bOK + +end function +'------------------------------------------------------------------------- +function fCloseDatabase(optional bSave) + '/// close the database + '/// <u>parameter:</u> + '/// <b><i>optional</i>bSave:</b> if true the the database is saved if false then the changes are lost + sleep(1) + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + Database.useMenu + hMenuSelectNr 1 + hMenuSelectNr 5 + + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + sleep(1) + +end function +'------------------------------------------------------------------------- +sub sCloseAllToolbars + + Kontext "FormControls" + if FormControls.exists(1) then + FormControls.close() + endif + + Kontext "MoreControls" + if MoreControls.exists(1) then + MoreControls.close() + endif + + Kontext "FormDesignTools" + if FormDesignTools.exists(1) then + FormDesignTools.close() + endif + +end sub +'------------------------------------------------------------------------- +function tools_dbtools_fgetMySQLJDBCDatabaseProperties(sDBConfigFileName as string) + '/// return the databaseserver properties from the environment directory + '/// <u>parameter:</u> + '/// <br> + '/// <u>return:</u> + '/// the properties as an array + '/// entry 1 defined (yes or no) + '/// entry 2 server name + '/// entry 3 database name + '/// entry 4 database port + '/// entry 5 database user name + '/// entry 6 database user password + '/// entry 7 jdbc driver file path + + tools_dbtools_fgetMySQLJDBCDatabaseProperties = fgetGenericDatabaseProperties( sDBConfigFileName, "mysql_jdbc" ) + +end function +'------------------------------------------------------------------------- +function tools_dbtools_fgetMySQLODBCDatabaseProperties() + '/// return the databaseserver properties from the environment directory + '/// <u>parameter:</u> + '/// <br> + '/// <u>return:</u> + '/// the properties as an array + '/// entry 1 defined (yes or no) + '/// entry 2 odbc dsn name + '/// entry 3 database user name + '/// entry 4 database user password + + dim i as integer + dim b(10000) as String + dim c + c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "mysql_odbc" , "" , "" ) + + ' split the string at = and return the right part + for i = 1 to 4 + 'printlog b(i) + b(i) = Right(b(i),len(b(i))-Instr(b(i),"=")) + 'printlog b(i) + next + + tools_dbtools_fgetMySQLODBCDatabaseProperties = b() + +end function +'------------------------------------------------------------------------- +function tools_dbtools_fgetAdabasDatabaseProperties() + '/// return the databaseserver properties from the environment directory + '/// <u>parameter:</u> + '/// <br> + '/// <u>return:</u> + '/// the properties as an array + '/// entry 1 defined (yes or no) + '/// entry 2 server name + '/// entry 3 database name + '/// entry 4 database user name + '/// entry 5 database user password + + dim i as integer + dim b(10000) as String + dim c + c = hGetDataFileSection( gTesttoolPath + gPrivateEnvironmentLocation + "input/base.txt", b(), "adabas" , "" , "" ) + + ' split the string at = and return the right part + for i = 1 to 5 + 'printlog b(i) + b(i) = Right(b(i),len(b(i))-Instr(b(i),"=")) + 'printlog b(i) + next + + tools_dbtools_fgetAdabasDatabaseProperties = b() + +end function +'------------------------------------------------------------------------------- +function fgetGenericDatabaseProperties(sDBConfigFileName as string, sType as String) + + dim i as integer + dim b(10000) as String + dim c + c = hGetDataFileSection( sDBConfigFileName, b(), sType , "" , "" ) + + ' split the string at = and return the right part + for i = 1 to 7 + if(VERBOSE) then + printlog "orig. string : " + b(i) + endif + b(i) = Right(b(i),len(b(i))-Instr(b(i),"=")) + if(VERBOSE) then + printlog "string after the '=' : " + b(i) + endif + next + + + + + fgetGenericDatabaseProperties = b() + +end function diff --git a/testautomation/dbaccess/tools/formtools.inc b/testautomation/dbaccess/tools/formtools.inc new file mode 100755 index 000000000000..ef7105ccef22 --- /dev/null +++ b/testautomation/dbaccess/tools/formtools.inc @@ -0,0 +1,193 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Helper Routines for Base tests. +'* +'*************************************************************************************** +'* +'* #1 fOpenNewFormDesign +'* #1 fCloseForm +'* #1 fSaveForm +'* #1 fOpenForm +'* #1 fFindForm +'* +'\*********************************************************************************** +'------------------------------------------------------------------------- +function fOpenNewFormDesign() + '/// open a a new form design from an open database + '/// <u>parameter:</u> + + Kontext "DATABASE" + if ( Database.NotExists(3) ) then + fOpenNewFormDesign = false + exit function + end if + + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + sleep(1) + + ViewForms + NewFormDesign + + sleep(2) + + fOpenNewFormDesign = true + +end function +'-------------------------------------------------------------------- +function fCloseForm( optional bSave ) + '/// close an open form + '/// <u>parameter:</u> + '/// <b><i>optional</i> bSave:</b> if true the form shall be saved, if false the changes are lost + + sleep(1) + + Kontext "DocumentWriter" + DocumentWriter.UseMenu + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(5) ' the Close Window + + 'when issue 30401 is fixed this has to be changed + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + sleep(1) + + fCloseForm = true + +end function +'-------------------------------------------------------------------- +function fSaveForm( sFormName as string, optional bCloseForm as boolean ) + '/// save an open form with the given name + '/// <u>parameter:</u> + '/// <b>sFormName:</b> the name under which the form shall be saved. If the file allready exists, then the file will be overwritten + '/// <b><i>optional</i> bCloseForm:</b> if true the form shall be closed after saving, if false form stay open + sleep(1) + + Kontext "DocumentWriter" + DocumentWriter.UseMenu + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(6) ' the Save + + Kontext "FormSaveDialog" + if FormSaveDialog.exists(3) then + FormName.setText(sFormName) + SaveBtn.Click + 'click yes in the overwrite messages box + Kontext "MessageBox" + if MessageBox.exists(1) then + MessageBox.Yes + endif + fSaveForm = true + else + fSaveForm = false + end if + + if ( IsMissing( bCloseForm ) ) then + ' nothing + else + call fCloseForm() + end if + +end function +'-------------------------------------------------------------------- +function fOpenForm(sFormName as string) + '/// open a form with the given name + '/// <u>parameter:</u> + '/// <b>sFormName:</b> the name of the form which shall be open + + if ( fFindForm(sFormName) = true ) then + printlog "Form found -> open" + Kontext "ContainerView" + OpenForm ' uno-Slot .uno:DB/Open + sleep(1) + fOpenForm = true + else + printlog "Form not found." + fOpenForm = false + end if + +end function +'-------------------------------------------------------------------- +function fFindForm(sFormName as string) + '/// select a form with the given name + '/// <u>parameter:</u> + '/// <b>sFormName:</b> the name of the form which shall be selected + + Dim iNumbersOfForms as integer + Dim i as integer + + Kontext "ContainerView" + + ViewForms + + fFindForm = false + + if ( Not FormTree.exists(1) ) then + warnlog "The form tree doesn't exists" + exit function + end if + + iNumbersOfForms = FormTree.getItemCount() + + ' this select the first entry + FormTree.TypeKeys "<HOME>" + FormTree.TypeKeys "<UP>" + + + for i = 1 to iNumbersOfForms + + FormTree.TypeKeys "<ADD>" + 'printlog "i = " + i + 'printlog "FormName.getItemCount = " + FormTree.getItemCount + if FormTree.getItemCount > iNumbersOfForms then + iNumbersOfForms = FormTree.getItemCount() + endif + 'printlog "FormName.getSeltext = " + FormTree.getSeltext + if FormTree.getSeltext = sFormName then + fFindForm = true + exit for + endif + FormTree.TypeKeys "<DOWN>" + next + sleep(1) + +end function diff --git a/testautomation/dbaccess/tools/querytools.inc b/testautomation/dbaccess/tools/querytools.inc new file mode 100755 index 000000000000..7dc3d7278938 --- /dev/null +++ b/testautomation/dbaccess/tools/querytools.inc @@ -0,0 +1,434 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Helper Routines for Base tests. +'* +'*************************************************************************************** +'* +' #1 fFindQuery +' #1 fOpenNewQueryDesign +' #1 fStartQueryWizard +' #1 fCloseQueryDesign +'* +'\*********************************************************************************** +'------------------------------------------------------------------------- +function fFindQueryInBeamer(sDSName1,sQueryName1) + '/// select a query with the given name in the beamer + '/// <u>parameter:</u> + '/// <b>sDSName1:</b> the name of the datasource + '/// <b>sQueryName1:</b> the name of the query + + dim i as integer + dim bfindQuery as boolean + dim iNoDS as integer + dim iNoQuery as integer + + bfindQuery = false + Kontext "DatabaseBeamer" + Kontext "DatabaseSelection" + + iNoDS = DatabaseSelection.getItemCount + for i = 1 to iNoDS + DatabaseSelection.Select i + if DatabaseSelection.getText = sDSName1 then + i = iNoDS + endif + next i + + wait 500 + DatabaseSelection.TypeKeys "<ADD>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + DatabaseSelection.TypeKeys "<ADD>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + + + iNoQuery = DatabaseSelection.getItemCount + dim ii as integer + ii = DatabaseSelection.GetSelIndex + for i = ii to iNoQuery + DatabaseSelection.Select i + if DatabaseSelection.getText = sQueryName1 then + i = iNoQuery + sleep 1 + bfindQuery = true + endif + next i + + fFindQuery = bfindQuery + +end function +'-------------------------------------------------------------------- +function fOpenNewQueryDesign() as boolean + '/// open a new query design + '/// <u>parameter:</u> + + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + if ( Database.NotExists(3) ) then + fOpenNewQueryDesign = false + warnlog "The database windows doesn't exists" + exit function + end if + + sleep(1) + + printlog "open new query design" + + NewQueryDesign + + fOpenNewQueryDesign = true + +end function +'-------------------------------------------------------------------- +function fOpenNewSQLQueryDesign() as boolean + '/// open a new query design in SQL mode + '/// <u>parameter:</u> + + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + if ( Database.NotExists(3) ) then + fOpenNewSQLQueryDesign = false + warnlog "The database windows doesn't exists" + exit function + end if + + sleep(1) + + printlog "open new sql query design" + + NewSQLQueryDesign + + fOpenNewSQLQueryDesign = true + +end function +'------------------------------------------------------------------------- +function fStartQueryWizard() + '/// start the query wizard + '/// <u>parameter:</u> + + Kontext "DATABASE" + if ( Database.NotExists(3) ) then + fStartQueryWizard = false + exit function + end if + + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + sleep(1) + + ViewQueries + StartQueryWizard + + sleep(2) + + fStartQueryWizard = true + +end function +'------------------------------------------------------------------------- +function fCloseQueryDesign(optional bSave) + '/// close the query design + '/// <u>parameter:</u> + '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost + + sleep(1) + + Kontext "QueryDesignTable" + QueryDesignTable.UseMenu + ' bug file / close close the whole database + 'hMenuSelectNr(1) ' the file menu + 'hMenuSelectNr(4) ' the Close Window + + hMenuSelectNr(6) ' the window menu + hMenuSelectNr(1) ' the Close Window + + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fOpenQueryInSQLDesign(sQueryName as String) + '/// open a query in sql design + '/// <u>parameter:</u> + '/// <b>bQueryName:</b> the name of the query which should be open + + if ( fFindQuery(sQueryName) = true ) then + printlog "Query " + sQueryName + " found -> open in sql design" + + Kontext "DATABASE" + Database.UseMenu + + hMenuSelectNr(2) + hMenuSelectNr(9) + + sleep(1) + fOpenQueryInSQLDesign= true + else + fOpenQueryInSQLDesign = false + end if + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCloseSQLQueryDesign(optional bSave) + '/// close the query design + '/// <u>parameter:</u> + '/// <b><i>optional</i>bSave:</b> if true the query is saved if false then the changes are lost + + sleep(1) + + Kontext "QueryEditWindow" + QueryEditWindow.UseMenu + ' bug file / close close the whole database + 'hMenuSelectNr(1) ' the file menu + 'hMenuSelectNr(4) ' the Close Window + + hMenuSelectNr(6) ' the window menu + hMenuSelectNr(1) ' the Close Window + + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + sleep(1) + +end function +'------------------------------------------------------------------------- +function fSaveQueryDesign(sName as String) + '/// save an open Query Design + '/// <u>parameter:</u> the name of query + + sleep(1) + Kontext "QueryDesignTable" + DatabaseSave + + Kontext "DatabaseTableSaveAs" + TableName.setText(sName) + DatabaseTableSaveAs.OK + + sleep(1) + + fSaveQueryDesign = true + +end function +'------------------------------------------------------------------------- +function fSaveSQLQueryDesign(sName as String) + '/// save an open SQL Query Design + '/// <u>parameter:</u> the name of query + + sleep(1) + + Kontext "QueryEditWindow" + DatabaseSaveAs + + Kontext "DatabaseTableSaveAs" + TableName.setText(sName) + DatabaseTableSaveAs.OK + + sleep(1) + + fSaveSQLQueryDesign = true + +end function + +'------------------------------------------------------------------------- +function fChooseTableInAddTableDialog(sTableName as string) as boolean + Kontext "AddTables" + if ( not AddTables.exists(1) ) then + fChooseTableInQueryAddTableDialog = false + exit function + endif + + 'TODO: add a test to click on the execute button, before the add table dialog is closed. + dim ix as integer + dim i as integer + ix = TableName.getItemCount + for i = 1 to ix + TableName.Select i + TableName.TypeKeys "<ADD>" + 'printlog "ix = " + ix + 'printlog "TableName.getItemCount = " + TableName.getItemCount + if TableName.getItemCount > ix then + ix = TableName.getItemCount + 'printlog "TableName.getItemCount > ix" + endif + 'printlog "TableName.getSeltext = " + TableName.getSeltext + if TableName.getSeltext = sTableName then + i = ix + endif + next + if TableName.getSeltext <> sTableName then + warnlog "Can find the table " + sTableName + "." + _ + "Make sure that the table exists when starting this test." + DatabaseClose + sleep(5) + Kontext "Messagebox" + if Messagebox.Exists(3) then + if Messagebox.getRT = 304 then + Messagebox.No + end if + end if + call hCloseDocument + exit function + endif + printlog "- Add " + sTableName +" table to query design" + '/// Add database table to Query. + AddTable.Click + sleep(2) + if AddTables.exists(2) then + CloseDlg.Click ' When the AddTables dialog still exists then close him + endif + sleep(1) + fChooseTableInAddTableDialog = true + +end function +'-------------------------------------------------------------------- +function fOpenQuery(sQueryName as string) + '/// open the query with the given name + '/// <u>parameter:</u> + '/// <b>squeryName:</b> the query which shall be opened + if ( fFindQuery(sQueryName) = true ) then + printlog "Query " + sQueryName + " found -> open" + Kontext "ContainerView" + OpenTable ' uno-Slot .uno:DB/Open + sleep(1) + fOpenQuery = true + else + fOpenQuery = false + end if + +end function +'-------------------------------------------------------------------- +function fFindQuery(sQueryName as string) + '/// select the Query with the given name in the Query container + '/// <u>parameter:</u> + '/// <b>sQueryName:</b> the Query which shall be selected + + Dim iNumbersOfQuerys as integer + Dim i as integer + + Kontext "ContainerView" + + ViewQueries + + fFindQuery = false + + if ( Not QueriesTree.exists(1) ) then + qaerrorlog "The Query tree doesn't exists" + ' May be a messagebox appear click OK to close it + Kontext "MessageBox" + if MessageBox.exists(1) then + qaerrorlog MessageBox.getText() + while MessageBox.exists() ' sometimes there are more then 1 message boxe + MessageBox.OK + wend + endif + exit function + end if + + iNumbersOfQuerys = QueriesTree.getItemCount() + + ' this select the first entry + QueriesTree.TypeKeys "<HOME>" + QueriesTree.TypeKeys "<UP>" + + + for i = 1 to iNumbersOfQuerys + + QueriesTree.TypeKeys "<ADD>" + 'printlog "i = " + i + 'printlog "QueryName.getItemCount = " + QueriesTree.getItemCount + if QueriesTree.getItemCount > iNumbersOfQuerys then + iNumbersOfQuerys = QueriesTree.getItemCount() + endif + 'printlog "QueryName.getSeltext = " + QueriesTree.getSeltext + if QueriesTree.getSeltext = sQueryName then + fFindQuery = true + exit for + endif + QueriesTree.TypeKeys "<DOWN>" + next + sleep(1) + +end function +'------------------------------------------------------------------------- +function fCloseQueryView() + '/// close an open Query view + '/// <u>parameter:</u> + + sleep(1) + + Kontext "TableView" + TableView.UseMenu + ' bug file / close close the whole database + 'hMenuSelectNr(1) ' the file menu + 'hMenuSelectNr(4) ' the Close Window + + hMenuSelectNr(5) ' the window menu + hMenuSelectNr(1) ' the Close Window + ' if messages box appear because of unsaved record click no in the dialog + Kontext "Messagebox" + if Messagebox.Exists(3) then + Messagebox.No + end if + + fCloseQueryView = true +end function diff --git a/testautomation/dbaccess/tools/reporttools.inc b/testautomation/dbaccess/tools/reporttools.inc new file mode 100755 index 000000000000..70b9ff129bd5 --- /dev/null +++ b/testautomation/dbaccess/tools/reporttools.inc @@ -0,0 +1,387 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Report Helper Routines for Base tests. +'* +'*************************************************************************************** +'* +'* #1 fOpenNewReoprtDesign +'* #1 fCloseReportDesign +'* #1 fCloseReportView +'* #1 fSaveReport +'* #1 fOpenReport +'* #1 fFindREport +'* #1 fOpenReportNavigator +'* #1 fCloseReportNavigator +'* #1 fSwitchPageheader +'* #1 fExecutereport +'* #1 fCloseAddFieldDialog +'* #1 tools_reporttools_InstallExtension +'* +'\*********************************************************************************** +'------------------------------------------------------------------------- +function fOpenNewReportDesign() + '/// open a a new report design from an open database + '/// <u>parameter:</u> + + Kontext "DATABASE" + if ( Database.NotExists(3) ) then + fOpenNewReportDesign = false + exit function + end if + + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + sleep(1) + + ViewReports + NewReportDesign + + sleep(5) + + ' Kontext "ReportDesign" + ' ReportDesign.MouseDown(50,50) + ' ReportDesign.MouseUp(50,50) + + ' sleep(1) + + fOpenNewReportDesign = true + +end function +'-------------------------------------------------------------------- +function fCloseReportDesign( optional bSave ) + '/// close an open Report + '/// <u>parameter:</u> + '/// <b><i>optional</i> bSave:</b> if true the Report shall be saved, if false the changes are lost + + sleep(1) + + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(5) ' the Close Window + + 'when issue 30401 is fixed this has to be changed + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + sleep(1) + + fCloseReportDesign = true + +end function +'-------------------------------------------------------------------- +function fCloseReportView() + '/// close an open Report View + '/// <u>parameter:</u> + + sleep(1) + + Kontext "DocumentWriter" + DocumentWriter.UseMenu + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(5) ' the Close Window + + sleep(1) + + fCloseReportView = true + +end function +'-------------------------------------------------------------------- +function fSaveReport( sReportName as string, optional bCloseReport as boolean ) + '/// save an open Report with the given name + '/// <u>parameter:</u> + '/// <b>sReportName:</b> the name under which the Report shall be saved. If the file allready exists, then the file will be overwritten + '/// <b><i>optional</i> bCloseReport:</b> if true the Report shall be closed after saving, if false Report stay open + sleep(1) + + Kontext "DocumentWriter" + DocumentWriter.UseMenu + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(6) ' the Save + + Kontext "ReportSaveDialog" + if FormSaveDialog.exists(3) then + FormName.setText(sReportName) + SaveBtn.Click + 'click yes in the overwrite messages box + Kontext "MessageBox" + if MessageBox.exists(1) then + MessageBox.Yes + endif + fSaveReport = true + else + fSaveReport = false + end if + + if ( IsMissing( bCloseReport ) ) then + ' nothing + else + call fCloseReportDesign() + end if + +end function +'-------------------------------------------------------------------- +function fOpenReport(sReportName as string) + '/// open a Report with the given name + '/// <u>parameter:</u> + '/// <b>sReportName:</b> the name of the Report which shall be open + + if ( fFindReport(sReportName) = true ) then + printlog "Report found -> open" + Kontext "ContainerView" + OpenForm ' uno-Slot .uno:DB/Open + sleep(1) + fOpenReport = true + else + printlog "Report not found." + fOpenReport = false + end if + +end function +'-------------------------------------------------------------------- +function fOpenReportInDesign(sReportName as string) + '/// open a Report with the given name in the design mode + '/// <u>parameter:</u> + '/// <b>sReportName:</b> the name of the Report which shall be open + + if ( fFindReport(sReportName) = true ) then + printlog "Report found -> open" + Kontext "ContainerView" + EditReport ' uno-Slot .uno:DB/Edit + sleep(1) + fOpenReportInDesign = true + else + printlog "Report not found." + fOpenReportInDesign = false + end if + +end function +'-------------------------------------------------------------------- +function fFindReport(sReportName as string) + '/// select a Report with the given name + '/// <u>parameter:</u> + '/// <b>sReportName:</b> the name of the Report which shall be selected + + Dim iNumbersOfReports as integer + Dim i as integer + + Kontext "DATABASE" + + ViewReports + + fFindReport = false + + if ( Not DatabaseReportsView.exists(1) ) then + warnlog "The Report tree doesn't exists" + exit function + end if + + iNumbersOfReports = DatabaseReportsView.getItemCount() + + ' this select the first entry + DatabaseReportsView.TypeKeys "<HOME>" + DatabaseReportsView.TypeKeys "<UP>" + + + for i = 1 to iNumbersOfReports + + DatabaseReportsView.TypeKeys "<ADD>" + 'printlog "i = " + i + 'printlog "ReportName.getItemCount = " + ReportTree.getItemCount + if DatabaseReportsView.getItemCount > iNumbersOfReports then + iNumbersOfReports = DatabaseReportsView.getItemCount() + endif + 'printlog "ReportName.getSeltext = " + ReportTree.getSeltext + if DatabaseReportsView.getSeltext = sReportName then + fFindReport = true + exit for + endif + DatabaseReportsView.TypeKeys "<DOWN>" + next + sleep(1) + +end function +'-------------------------------------------------------------------- +function fOpenReportNavigator + '/// open the report navigator + '/// <u>parameter:</u> + printlog "open report navigator" + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(3) + if (hMenuItemIsChecked(5) = false) then + hMenuSelectNr(5) + else + 'nothing + endif + + sleep(1) + +end function +'-------------------------------------------------------------------- +function fCloseReportNavigator + '/// open the report navigator + '/// <u>parameter:</u> + printlog "open report navigator" + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(3) + if (hMenuItemIsChecked(5) = true) then + hMenuSelectNr(5) + else + 'nothing + endif + + sleep(1) + +end function +'-------------------------------------------------------------------- +function fExecuteReport + '/// execute the report via the menu + '/// <u>parameter:</u> + + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(2) + hMenuSelectNr(14) + +end function +'-------------------------------------------------------------------- +function fSwitchPageHeader + '/// delete or insert the Page Header via the menu + '/// <u>parameter:</u> + + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(2) + hMenuSelectNr(8) + +end function +'-------------------------------------------------------------------- +function fCloseAddFieldDialog + '/// close the Add Field Dialog via the slot or menu + '/// <u>parameter:</u> + + Kontext "ReportAddField" + if (ReportAddField.exists(3)) then + ReportAddField.close + else + ' check if the dialog is really not there + ' sometimes the focus is wrong. So I try a second way to disable the dialog + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(3) + if (hMenuItemIsChecked(3)) then + hMenuSelectNr(3) + else + warnlog "there should be the Add field dialog. But there is none." + endif + endif +end function +'-------------------------------------------------------------------- +function fOpenAddFieldDialog + '/// open the Add Field Dialog via the slot or menu + '/// <u>parameter:</u> + + Kontext "ReportAddField" + if (ReportAddField.exists(3)) then + ' do nothing + else + Kontext "ReportDesign" + ReportDesign.UseMenu + hMenuSelectNr(3) + if (hMenuItemIsChecked(3)) then + hMenuSelectNr(3) + ReportDesign.UseMenu + hMenuSelectNr(3) + hMenuSelectNr(3) + printlog "1" + else + hMenuSelectNr(4) + printlog "2" + endif + Kontext "ReportAddField" + ReportAddField + if (ReportAddField.exists(3)) then + ' do nothing + else + warnlog "there should be the Add field dialog. But there is none." + endif + endif + +end function +'-------------------------------------------------------------------- +function tools_reporttools_InstallExtension + '/// install the report designer extension + '/// <u>parameter:</u> + '/// <u>Return Value:</u><br> + + '/// <ol> + '/// +<li>Errorcode (Integer)</li> + '/// <ul> + '/// <li>0 = No errors, extension was added correctly</li> + '/// <li> not 0 = an error occure see hExtensionAddGUI for more info </li> + '/// </ul> + '/// </ol> + + dim i as integer + use "global/tools/includes/optional/t_extension_manager_tools.inc" + if (not hIsExtensionAlreadyInstalled("Report Builder")) then + i = hExtensionAddGUI( gTesttoolPath + "dbaccess/required/input/oracle-report-builder.oxt", "AcceptLicense,InstallForUser" ) + if (i > 0) then + tools_reporttools_InstallExtension = 0 + else + if (i = -5) then + warnlog "Report extension was not installed due to unsatisfied dependencies." + tools_reporttools_InstallExtension = 5 + else + warnlog "Report extension was not installed. Error Code = " + i + tools_reporttools_InstallExtension = i + endif + endif + else + tools_reporttools_InstallExtension = 0 + endif + + ' restart the office + call ExitRestartTheOffice + +end function diff --git a/testautomation/dbaccess/tools/tabletools.inc b/testautomation/dbaccess/tools/tabletools.inc new file mode 100755 index 000000000000..1f6dd23de53d --- /dev/null +++ b/testautomation/dbaccess/tools/tabletools.inc @@ -0,0 +1,771 @@ +'encoding UTF-8 Do not remove or change this line! +'************************************************************************** +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'/************************************************************************ +'* +'* owner : marc.neumann@oracle.com +'* +'* short description : Tools for Tables +'* +'************************************************************************ +'* +' #1 fCloseRelationDesign +' #1 fCloseTableDesign +' #1 fCloseTableView +' #1 fCompareMatrixValues +' #1 fCreateRefFile +' #1 fCreateTable +' #1 fDeleteTable +' #1 fFindTable +' #1 fInsertIntoTable +' #1 fOpenRelationDesign +' #1 fOpenNew TableDesign +' #1 fOpenTable +' #1 fReadFile +'* +'\*********************************************************************** +'------------------------------------------------------------------------------ +function tCompareMatrixValues(sDSName as string, sRefFileUrl as string, cTable_or_Query as string, sTableName as string, iRowPos as integer, iColPos as integer, sWordSeperator as string) as integer + 'sDSName = data source name f.e. Bibliography + 'sRefFileUrl = URL to your reference file (os indipendent - extension .ttr) f.e. base\optional\input\reference_tables\test.ttr + 'cTable_or_Query = differ between comparing reference file with a table (t) or a query-table (q) + 'sTableName = name of table or query-table to compare with f.e. Table1 + 'iRowPos,iColPos = row and column amount of reference and comparing table (must have the same size ; begin with 1 ; 0 is leftout, but has to be added) + + dim i as integer + dim j as integer 'counter' + dim aMatrix(iRowPos, iColPos) as string + + printlog "" + if cTable_or_Query = "t" then printlog "--- Compare Table with Reference Table ---" + if cTable_or_Query = "q" then printlog "--- Compare Query with Reference Table ---" + + call fReadFile(sRefFileUrl, aMatrix(), sWordSeperator) + + call hNewDocument + + '/// open Beamer and open datasource + ViewCurrentDatabase + sleep(1) + printlog "open database beamer" + + '/// switch between table and querie search + dim bfind_ok as boolean 'placeholder + if cTable_or_Query = "t" then + bfind_ok = ffindTableInBeamer(sDSName,sTableName) + printlog "found proper Table: " & sTableName + endif + if cTable_or_Query = "q" then + bfind_ok = ffindQuery(sDSName, sTableName) + printlog "found proper Query: " & sTableName + endif + + if bfind_ok then + '/// Choosing for the right table + sleep(1) + Kontext "DatabaseSelection" + DatabaseSelection.TypeKeys "<MOD1 SHIFT E>",TRUE ' # type CTRL + SHIFT + E to go from the DatabaseSelection to the TableView' + sleep(1) + printlog "found and opened proper table" + '/// comparing data in table with reference table + printlog "start comparing data in table with reference table" + Kontext "TableView" + dim ivalue_ok as integer + ivalue_ok = 0 + TableView.TypeKeys "<TAB>",TRUE + TableView.TypeKeys "<HOME>",TRUE + TableView.TypeKeys "<HOME>",TRUE + for i = 1 to iRowPos -1 + for j = 1 to iColPos -1 + setclipboard("") + 'here the values are read out and put in clipboard for comparing + TableView.TypeKeys "<MOD1 C>",TRUE + TableView.TypeKeys "<TAB>",TRUE + 'printlog "i: " & i + 'printlog "j: " & j + 'printlog "getClipboard: " & getclipboard() + 'printlog "matrix: " & aMatrix(i,j) + + 'here the values are compared + if getclipboard() <> aMatrix(i,j) then + ivalue_ok = ivalue_ok + 1 + warnlog ivalue_ok & ". fault in pos(row/col): " & i & "/" & j & " - should be: " & aMatrix(i,j) & " but is: " & getclipboard() + endif + 'printlog ivalue_ok & ". No !!! foult but TEST - should be: " & aMatrix(i,j) & " but is: " & getclipboard() + next j + next i + + '/// Result part + if ivalue_ok = 0 then + printlog "** Comparing procedure without faults" + tCompareMatrixValues = ivalue_ok + else + warnlog "Comparing procedure went wrong: " + ivalue_ok + " differences found!" + tCompareMatrixValues = 1 + endif + else + if cTable_or_Query = "t" then warnlog "Table: " + sTableName + " not found - Test aborted" + if cTable_or_Query = "q" then warnlog "Query: " + sTableName + " not found - Test aborted" + endif + printlog "*** End Testcase" + sleep 1 + ViewCurrentDatabase + hCloseDocument + +end function +'------------------------------------------------------------------------------ +function fCreateRefFile(sDSName as string, cTable_or_Query as string, sTableName as string, sWordSeperator as string) as string + dim bfind_ok as boolean 'check if right table found + dim iNumber as Integer 'needed for open reference file + dim iColAmount as integer + dim iRowAmount as integer 'counter + dim sReadContCol as string + dim sContColMem as string 'read out content string and its memo for getting table column ammount + dim sCellValue as string + dim sCellValueMem as string 'read out content string and its memo for writing in reference table + + dim sRefTableName as string + sRefTableName = ConvertPath("user\work\" & sTableName & ".ttr") + dim sRefFileUrl as string + sRefFileUrl = gOfficePath & sRefTableName + printlog "path for reference table: " & sRefFileUrl + + + call hNewDocument + + '/// open Beamer and open datasource + ViewCurrentDatabase + sleep(1) + printlog "open database beamer" + + '/// switch between table and querie search + if cTable_or_Query = "t" then + printlog "search for proper Table: " & sTableName + bfind_ok = ffindTableInBeamer(sDSName,sTableName) + endif + if cTable_or_Query = "q" then + printlog "search for proper Query: " & sTableName + bfind_ok = ffindQuery(sDSName, sTableName) + endif + + if bfind_ok then + '/// jumping to the right table + sleep(1) + Kontext "DatabaseSelection" + DatabaseSelection.TypeKeys "<MOD1 SHIFT E>",TRUE ' # type CTRL + SHIFT + E to go from the DatabaseSelection to the TableView' + sleep(1) + + '/// check the row and column amount + printlog "check the row and column amount" + Kontext "TableView" + sReadContCol = 1 'init + sContColMem = 1 'init + iColAmount = 0 'init + iRowAmount = AllRecords.caption() + while sReadContCol = sContColMem + sContColMem = sReadContCol + sReadContCol = CurrentRecord.getText() + TableView.TypeKeys "<TAB>",TRUE + TableView.TypeKeys "<TAB>",TRUE + iColAmount = iColAmount +1 + wend + iColAmount = iColAmount -1 + 'printlog "sReadContCol: " & sReadContCol + printlog "size of table (columns/rows): " & iColAmount & "/" & iRowAmount + fCreateRefFile = iColAmount & "," & iRowAmount + TableView.TypeKeys "<UP>",TRUE + TableView.TypeKeys "<HOME>",TRUE + TableView.TypeKeys "<HOME>",TRUE + sleep(1) + + '/// reading out values from table, create a reference table and input values in + printlog "start reading out values from table and writing in ref table" + iNumber = Freefile + dim i as integer 'counter + dim j as integer 'counter + Open sRefFileUrl for Output as iNumber + for i = 1 to iRowAmount + for j = 1 to iColAmount + Kontext "TableView" + TableView.TypeKeys "<MOD1 C>" + sCellValue = getclipboard() + TableView.TypeKeys "<TAB>" + if j <> 1 then + sCellValueMem = sCellValueMem & sWordSeperator + endif + sCellValueMem = sCellValueMem & sCellValue + 'printlog i & j & " inhalt: " & sCellValue + setclipboard("") + next j + print #iNumber, sCellValueMem + sCellValueMem = "" + next i + Close #iNumber + sleep(1) + + '/// warning if table not found - without proper table the test make no sense + else + warnlog "Table: " + sTableName + " not found." + fCreateRefFile = "" + endif + + sleep 1 + ViewCurrentDatabase + hCloseDocument + +end function +'------------------------------------------------------------------------------ +function fReadFile(sRefFileUrl as string, aMatrix() as string, sWordSep as string) + 'connecting and opening file + dim iNumber as Integer + iNumber = Freefile + 'position and content variables + dim sColumn As String + dim iRowPos as integer + dim iColPos as integer + dim iPos as integer + dim iPos1 as integer 'pointer for searching position + + 'init position in matrix + iRowPos = 1 + iColPos = 1 + + '/// open reference file and store it into an array (matrix) + printlog "search for the reference file, open it and store content in an array" + sRefFileUrl = gOfficePath + ConvertPath(sRefFileUrl) + Open sRefFileUrl for Input as iNumber + while not eof(iNumber) + Line Input #iNumber, sColumn + iPos1 = 1 'startposition + iPos = 1 'startposition + while iPos <> 0 'if iPos = 0 then no more sWordSeperator found -> end of column reached + iPos = Instr(iPos +1,sColumn,sWordSep) 'check column for sWordSeperator + 'printlog "iPos: " & iPos + 'printlog "iPos1: " & iPos1 + if iPos <> 1 then '<> 1 -> no content found + aMatrix(iRowPos,iColPos) = Mid(sColumn,iPos1,iPos - iPos1) 'cut content and put into array + 'printlog "iRow: " & iRowPos + 'printlog "iCol: " & iColPos + 'printlog "aMatrix: " & aMatrix(iRowPos,iColPos) + iPos1 = iPos +1 + iColPos = iColPos +1 + else warnlog "reference file is empty" + endif + wend + iRowPos = iRowPos +1 + iColPos = 1 + wend + printlog "**end of reading out reference table" +end function +'-------------------------------------------------------------------- +function fCreateTable(aFieldTypeContent(),sTableName,optional sCatalog,optional sSchema) + '/// create a table with the given FieldTypes + '/// sSchema and sCatalog are optional. + '/// If the optional parameter is not given then it's set to "" + '/// <u>parameter:</u> + '/// <b>aFieldTypeContent:</b> an arry with the table field data + '/// the array have to look like the following + '/// array(1,1) = first_field_name + '/// array(1,2) = first_field_type + '/// array(2,1) = second_field_name + '/// array(2,2) = second_field_type + '/// ... + '/// <b>sTableName:</b> the name of the table + '/// <b><i>optional</i> sCatalog:</b> the name of the table catalog + '/// <b><i>optional</i> sSchema:</b> the name of the table schema + + Dim i as integer 'counter + Dim iFieldNumber as integer 'counter + dim iNoDS as integer 'number of data source in listbox + Dim iNumberOfFieldTypes as integer 'field type memory + Dim iFieldTypesCounter as integer 'counter + Dim iIndex as integer 'counter + Dim sFieldType as string 'help var for fieldtypes + Dim sTypeName as String 'help var for fieldtypes + + if ( IsMissing(sCatalog) ) then + sCatalog = "" + endif + + if ( IsMissing(sSchema) ) then + sSchema = "" + endif + + call fDeleteTable(sTableName) ' delete the table if exists + + call fOpenNewTableDesign + + Kontext "TableDesignTable" + + for iFieldNumber = 1 to ubound(aFieldTypeContent) - 1 + + printlog "create field : " + aFieldTypeContent(iFieldNumber,1) + Fieldname.TypeKeys aFieldTypeContent(iFieldNumber,1) , TRUE + Fieldname.TypeKeys "<RETURN>" , TRUE + sleep 1 + sTypeName = "[ " + aFieldTypeContent(iFieldNumber,2) + " ]" + iNumberOfFieldTypes = FieldType.getitemCount() + for iFieldTypesCounter = 1 to iNumberOfFieldTypes + sFieldType = FieldType.getitemText(iFieldTypesCounter) + iIndex = Instr(sFieldType,sTypeName) + if iIndex <> 0 then + printlog "FieldType : " + sFieldType + iFieldTypesCounter = iNumberOfFieldTypes ' stops the for loop if proper fieldtype found' + endif + next + '/// choose proper field type + FieldType.Select(sFieldType) 'listbox entry nr' + sleep 1 + FieldType.TypeKeys "<RETURN>" , TRUE + Description.TypeKeys "<RETURN>" , TRUE + printlog "-------------------------------" + next + + sleep(1) + + Kontext "TableDesignTable" + DatabaseSaveas + + Kontext "DatabaseTableSaveAs" + printlog "save table as "+ sTableName + TableName.setText sTableName + sleep(1) + '/// catalog handling + if sCatalog <> "" then + if Catalog.IsVisible then + Catalog.SetText sCatalog + printlog "inserting catalog name: " + sCatalog + else + warnlog "The Catalog-Name could not be inserted" + endif + endif + '/// schema handling + if sSchema <> "" then + if Schema.IsVisible then + Schema.SetText sSchema + printlog "inserting schema name: " + sSchema + else + warnlog "The Schema-Name could not be inserted" + endif + endif + DatabaseTableSaveAs.OK + sleep 1 + Kontext "Messagebox" + if Messagebox.Exists(1) then + Messagebox.Yes + printlog "create a primary key " + end if + sleep 1 + + ' a sql exception appear. Try to get the error text + Kontext "Messagebox" + if Messagebox.Exists(1) then + MessageBox.Click 5 ' click the more button + Kontext "SQLException" + if SQLException.exists() then + warnlog Errortext.getText() + SQlException.OK + end if + Kontext "MessageBox" + MessageBox.OK + end if + + call fCloseTableDesign + +end function +'-------------------------------------------------------------------- +function fDeleteTable(sTableName as string) + '/// delete the table with the given name + '/// <u>parameter:</u> + '/// <b>sTableName:</b> the table which shall be deleted + if ( fFindTable(sTableName) = true ) then + printlog "Table found press delete" + Kontext "ContainerView" + 'TableTree.TypeKeys "<DELETE>" , true + Delete ' uno-Slot .uno:DB/Delete + sleep(1) + Kontext "Active" + Active.Yes + fDeleteTable = true + else + fDeleteTable = false + end if + +end function +'-------------------------------------------------------------------- +function fOpenTable(sTableName as string) + '/// open the table with the given name + '/// <u>parameter:</u> + '/// <b>sTableName:</b> the table which shall be opened + if ( fFindTable(sTableName) = true ) then + printlog "Table found -> open" + Kontext "ContainerView" + OpenTable ' uno-Slot .uno:DB/Open + sleep(1) + fOpenTable = true + else + fOpenTable = false + end if + +end function +'-------------------------------------------------------------------- +function fFindTable(sTableName as string) + '/// select the table with the given name in the table container + '/// <u>parameter:</u> + '/// <b>sTableName:</b> the table which shall be selected + + Dim iNumbersOfTables as integer + Dim i as integer + + Kontext "ContainerView" + + ViewTables + + fFindTable = false + + if ( Not TableTree.exists(1) ) then + qaerrorlog "The table tree doesn't exists" + ' May be a messagebox appear click OK to close it + Kontext "MessageBox" + if MessageBox.exists(1) then + qaerrorlog MessageBox.getText() + while MessageBox.exists() ' sometimes there are more then 1 message boxe + MessageBox.OK + wend + endif + exit function + end if + + iNumbersOfTables = TableTree.getItemCount() + + ' this select the first entry + TableTree.TypeKeys "<HOME>" + TableTree.TypeKeys "<UP>" + + + for i = 1 to iNumbersOfTables + + TableTree.TypeKeys "<ADD>" + 'printlog "i = " + i + 'printlog "TableName.getItemCount = " + TableTree.getItemCount + if TableTree.getItemCount > iNumbersOfTables then + iNumbersOfTables = TableTree.getItemCount() + endif + 'printlog "TableName.getSeltext = " + TableTree.getSeltext + if TableTree.getSeltext = sTableName then + fFindTable = true + exit for + endif + TableTree.TypeKeys "<DOWN>" + next + sleep(1) + +end function +'-------------------------------------------------------------------- +function fInsertIntoTable( aFieldContent(), sTableName) + '/// insert data into a table + '/// <u>parameter:</u> + '/// <b>aFieldContent:</b> an arry with the table data + '/// the array have to look like the following + '/// array(1,1) = first_value_for_first_record + '/// array(1,2) = second_value_for_first_record + '/// array(2,1) = first_value_for_second_record + '/// array(2,2) = second_value_for_second_record + '/// ... + '/// <b>sTableName:</b> the name of the table + + Dim iCounterOfRecords as integer + Dim iCounterOfFields as integer + + Dim iNumberOfRecords as integer + Dim iNumberOfFields as integer + + iNumberOfRecords = ubound(aFieldContent) + iNumberOfFields = ubound(aFieldContent,2) + + call fOpenTable(sTableName) + + Kontext "TableView" + for iCounterOfRecords = 1 to iNumberOfRecords + for iCounterOfFields = 1 to iNumberOfFields + TableView.TypeKeys aFieldContent(iCounterOfRecords,iCounterOfFields),TRUE + TableView.TypeKeys "<TAB>",TRUE + next + next + + + sleep 1 + + call fCloseTableView + +end function +'------------------------------------------------------------------------- +function fCloseTableDesign(optional bSave) + '/// close an open table design + '/// <u>parameter:</u> + '/// <b><i>optional</i> bSave:</b> if true then the table design is saved + + sleep(1) + + Kontext "TableDesignTable" + TableDesignTable.UseMenu + ' bug file / close close the whole database + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(4) ' the Close Window + + 'hMenuSelectNr(6) ' the window menu + 'hMenuSelectNr(1) ' the Close Window + + Kontext "Messagebox" + if Messagebox.Exists(3) then + Messagebox.No + end if + + fCloseTableDesign = true +end function +'------------------------------------------------------------------------- +function fCloseTableView() + '/// close an open table view + '/// <u>parameter:</u> + + sleep(1) + + Kontext "TableView" + TableView.UseMenu + ' bug file / close close the whole database + 'hMenuSelectNr(1) ' the file menu + 'hMenuSelectNr(4) ' the Close Window + + hMenuSelectNr(6) ' the window menu + hMenuSelectNr(1) ' the Close Window + ' if messages box appear because of unsaved record click no in the dialog + Kontext "Messagebox" + if Messagebox.Exists(3) then + Messagebox.No + end if + + fCloseTableView = true +end function +'------------------------------------------------------------------------- +function fOpenRelationDesign() + '/// open a new relation design + '/// <u>parameter:</u> + + Kontext "DATABASE" + if ( Database.NotExists(3) ) then + fOpenRelationDesign = false + exit function + end if + + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + sleep(1) + + Database.UseMenu + hMenuSelectNr(5) + hMenuSelectNr(1) + + fOpenRelationDesign = true +end function +'------------------------------------------------------------------------- +function fCloseRelationDesign(optional bSave) + '/// close an open relation design + '/// <u>parameter:</u> + '/// <b><i>optional</i> bSave:</b> if true then the relation design is saved + + + Kontext "RelationDesign" + RelationDesign.UseMenu + ' bug file / close close the whole database + hMenuSelectNr(1) ' the file menu + hMenuSelectNr(4) ' the Close Window + + 'hMenuSelectNr(6) ' the window menu + 'hMenuSelectNr(1) ' the Close Window + + Kontext "Messagebox" + if Messagebox.Exists(3) then + if ( IsMissing( bSave ) ) then + Messagebox.No + else + if bSave then + Messagebox.Yes + else + Messagebox.No + endif + endif + end if + + fCloseRelationDesign = true +end function +'------------------------------------------------------------------------- +function fOpenNewTableDesign + printlog "fOpenNewTableDesign called" + + printlog "check if Database exists" + + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + if ( Database.NotExists(3) ) then + fOpenNewTableDesign = false + warnlog "The Database windows doesn't exists" + exit function + end if + + sleep(1) + + printlog "open new table design" + + NewTableDesign + + sleep(2) + + fOpenNewTableDesign = true + +end function +'------------------------------------------------------------------------- +function fOpenTableInDesign(sTableName as String) + printlog "fOpenTableInDesign called" + + printlog "check if Database exists" + + Kontext "DATABASE" + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + if ( Database.NotExists(3) ) then + fOpenTableInDesign = false + warnlog "The Database windows doesn't exists" + exit function + end if + + sleep(1) + + printlog "open new table design" + + call fFindTable(sTableName) + + EditTable + + Kontext "TableDesignTable" + if ( not TableDesignTable.exists(3) ) then + warnlog "The Table design doesn't open" + fOpenTableInDesign = false + exit function + end if + + fOpenTableInDesign = true + +end function +'------------------------------------------------------------------------- +function fFindTableInBeamer(sDSName1,sTableName1) + '/// select a table with the given name in the beamer + '/// <u>parameter:</u> + '/// <b>sDSName1:</b> the name of the datasource + '/// <b>sTableName1:</b> the name of the table + + dim i as integer + dim bfindTable as boolean + dim iNoDS as integer + dim iNoTable as integer + + bfindTable = false + Kontext "DatabaseBeamer" + Kontext "DatabaseSelection" + + iNoDS = DatabaseSelection.getItemCount + for i = 1 to iNoDS + DatabaseSelection.Select i + if DatabaseSelection.getText = sDSName1 then + i = iNoDS + bfindTable = true + endif + next i + + if (bfindTable = false) then + warnlog "Datasource " + sDSName1 + " not found!" + exit function + else + printlog "Datasource " + sDSName1 + " found!" + ' I set the bfindTable flag again back to false + ' for the next test of the table + bfindTable = false + endif + + wait 500 + DatabaseSelection.TypeKeys "<ADD>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + DatabaseSelection.TypeKeys "<ADD>" , true + wait 500 + DatabaseSelection.TypeKeys "<DOWN>" , true + wait 500 + + + iNoTable = DatabaseSelection.getItemCount + dim ii as integer + ii = DatabaseSelection.GetSelIndex + for i = ii to iNoTable + DatabaseSelection.Select i + if DatabaseSelection.getText = sTableName1 then + i = iNoTable + sleep 1 + bfindTable = true + endif + next i + + fFindTableInBeamer = bfindTable + +end function +'------------------------------------------------------------------------- +function fStartTableWizard() + '/// start the table wizard + '/// <u>parameter:</u> + + Kontext "DATABASE" + if ( Database.NotExists(3) ) then + fStartTableWizard = false + exit function + end if + + Database.MouseDown(50,50) + Database.MouseUp(50,50) + + sleep(1) + + ViewTables + StartTableWizard + + sleep(2) + + fStartTableWizard = true + +end function |