Renamed the modules for extension publishing. Changed to use dialogs instead of code-created dialogs for localized UI.
This commit is contained in:
parent
4816c5250d
commit
3ddf7f2d42
@ -1,4 +1,4 @@
|
|||||||
' _1CorRel: The macros to for generating the report of the Pearson’s correlation coefficient
|
' 1CorRel: The macros to for generating the report of the Pearson’s correlation coefficient
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
@ -6,151 +6,39 @@ Option Explicit
|
|||||||
' subRunCorrelation: Runs the Pearson’s correlation coefficient.
|
' subRunCorrelation: Runs the Pearson’s correlation coefficient.
|
||||||
Sub subRunCorrelation As Object
|
Sub subRunCorrelation As Object
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim mLabels () As String, nI As Integer, mSelected (0) As Integer
|
Dim oSheets As Object, sSheetName As String
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oSheet As Object, mRanges As Object
|
||||||
Dim oTextModel As Object, oListModel1 As Object, oListModel2 As Object
|
Dim sExisted As String, nResult As Integer
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim nColumn As Integer, oRange1 As Object, oRange2 As Object
|
|
||||||
Dim oSheets As Object, sSheetName As String, sExisted As String
|
|
||||||
Dim oSheet As Object
|
|
||||||
|
|
||||||
' Asks the user for the data range
|
' Asks the user for the data range
|
||||||
oRange = fnAskDataRange (ThisComponent)
|
oRange = fnAskDataRange (ThisComponent)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
ReDim mLabels (oRange.getColumns.getCount - 1) As String
|
|
||||||
For nI = 0 To oRange.getColumns.getCount - 1
|
|
||||||
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
|
||||||
Next nI
|
|
||||||
|
|
||||||
' Creates a dialog
|
' Specifies the data
|
||||||
oDialogModel = CreateUnoService ( _
|
mRanges = fnSpecifyData (oRange, _
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
"&3.Dlg2SpecData.txtPrompt1.Label1CorRel", _
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
"&6.Dlg2SpecData.txtPrompt2.Label1CorRel")
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
If IsNull (mRanges) Then
|
||||||
oDialogModel.setPropertyValue ("Height", 80)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 2/2: Specify the data")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "First score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptGroup", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel1 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel1.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel1.setPropertyValue ("PositionY", 15)
|
|
||||||
oListModel1.setPropertyValue ("Height", 10)
|
|
||||||
oListModel1.setPropertyValue ("Width", 85)
|
|
||||||
oListModel1.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 0
|
|
||||||
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstGroup", oListModel1)
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 30)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Second score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptScore", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel2 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel2.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel2.setPropertyValue ("PositionY", 40)
|
|
||||||
oListModel2.setPropertyValue ("Height", 10)
|
|
||||||
oListModel2.setPropertyValue ("Width", 85)
|
|
||||||
oListModel2.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 1
|
|
||||||
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstScore", oListModel2)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oButtonModel.setPropertyValue ("DefaultButton", True)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
|
||||||
oDialog.dispose
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If nResult = 0 Then
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange1 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange2 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
|
|
||||||
' Checks the existing report
|
' Checks the existing report
|
||||||
oSheets = ThisComponent.getSheets
|
oSheets = ThisComponent.getSheets
|
||||||
sSheetName = oRange1.getSpreadsheet.getName
|
sSheetName = oRange.getSpreadsheet.getName
|
||||||
sExisted = ""
|
|
||||||
If oSheets.hasByName (sSheetName & "_correl") Then
|
If oSheets.hasByName (sSheetName & "_correl") Then
|
||||||
sExisted = sExisted & ", """ & sSheetName & "_correl"""
|
sExisted = "Spreadsheet """ & sSheetName & "_correl"" exists. Overwrite?"
|
||||||
End If
|
|
||||||
If sExisted <> "" Then
|
|
||||||
sExisted = Right (sExisted, Len (sExisted) - 2)
|
|
||||||
If InStr (sExisted, ",") > 0 Then
|
|
||||||
sExisted = "Spreadsheets " & sExisted & " exist. Overwrite?"
|
|
||||||
Else
|
|
||||||
sExisted = "Spreadsheet " & sExisted & " exists. Overwrite?"
|
|
||||||
End If
|
|
||||||
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
||||||
If nResult = IDNO Then
|
If nResult = IDNO Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Drops the existing report
|
' Drops the existing report
|
||||||
If oSheets.hasByName (sSheetName & "_correl") Then
|
oSheets.removeByname (sSheetName & "_correl")
|
||||||
oSheets.removeByname (sSheetName & "_correl")
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Reports the paired T-test.
|
' Reports the paired T-test.
|
||||||
subReportCorrelation (ThisComponent, oRange1, oRange2)
|
subReportCorrelation (ThisComponent, mRanges (0), mRanges (1))
|
||||||
|
|
||||||
' Makes the report sheet active.
|
' Makes the report sheet active.
|
||||||
oSheet = oSheets.getByName (sSheetName & "_correl")
|
oSheet = oSheets.getByName (sSheetName & "_correl")
|
@ -1,4 +1,4 @@
|
|||||||
' _2PTTest: The macros to for generating the report of paired T-Test
|
' 2PTTest: The macros to for generating the report of paired T-Test
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-11
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-11
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
@ -6,151 +6,39 @@ Option Explicit
|
|||||||
' subRunPairedTTest: Runs the paired T-test.
|
' subRunPairedTTest: Runs the paired T-test.
|
||||||
Sub subRunPairedTTest As Object
|
Sub subRunPairedTTest As Object
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim mLabels () As String, nI As Integer, mSelected (0) As Integer
|
Dim oSheets As Object, sSheetName As String
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oSheet As Object, mRanges As Object
|
||||||
Dim oTextModel As Object, oListModel1 As Object, oListModel2 As Object
|
Dim sExisted As String, nResult As Integer
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim nColumn As Integer, oRange1 As Object, oRange2 As Object
|
|
||||||
Dim oSheets As Object, sSheetName As String, sExisted As String
|
|
||||||
Dim oSheet As Object
|
|
||||||
|
|
||||||
' Asks the user for the data range
|
' Asks the user for the data range
|
||||||
oRange = fnAskDataRange (ThisComponent)
|
oRange = fnAskDataRange (ThisComponent)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
ReDim mLabels (oRange.getColumns.getCount - 1) As String
|
|
||||||
For nI = 0 To oRange.getColumns.getCount - 1
|
|
||||||
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
|
||||||
Next nI
|
|
||||||
|
|
||||||
' Creates a dialog
|
' Specifies the data
|
||||||
oDialogModel = CreateUnoService ( _
|
mRanges = fnSpecifyData (oRange, _
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
"&3.Dlg2SpecData.txtPrompt1.Label1CorRel", _
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
"&6.Dlg2SpecData.txtPrompt2.Label1CorRel")
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
If IsNull (mRanges) Then
|
||||||
oDialogModel.setPropertyValue ("Height", 80)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 2/2: Specify the data")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "First score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptGroup", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel1 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel1.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel1.setPropertyValue ("PositionY", 15)
|
|
||||||
oListModel1.setPropertyValue ("Height", 10)
|
|
||||||
oListModel1.setPropertyValue ("Width", 85)
|
|
||||||
oListModel1.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 0
|
|
||||||
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstGroup", oListModel1)
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 30)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Second score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptScore", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel2 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel2.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel2.setPropertyValue ("PositionY", 40)
|
|
||||||
oListModel2.setPropertyValue ("Height", 10)
|
|
||||||
oListModel2.setPropertyValue ("Width", 85)
|
|
||||||
oListModel2.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 1
|
|
||||||
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstScore", oListModel2)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oButtonModel.setPropertyValue ("DefaultButton", True)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
|
||||||
oDialog.dispose
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If nResult = 0 Then
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange1 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange2 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
|
|
||||||
' Checks the existing report
|
' Checks the existing report
|
||||||
oSheets = ThisComponent.getSheets
|
oSheets = ThisComponent.getSheets
|
||||||
sSheetName = oRange1.getSpreadsheet.getName
|
sSheetName = oRange.getSpreadsheet.getName
|
||||||
sExisted = ""
|
|
||||||
If oSheets.hasByName (sSheetName & "_ttest") Then
|
If oSheets.hasByName (sSheetName & "_ttest") Then
|
||||||
sExisted = sExisted & ", """ & sSheetName & "_ttest"""
|
sExisted = "Spreadsheet """ & sSheetName & "_ttest"" exists. Overwrite?"
|
||||||
End If
|
|
||||||
If sExisted <> "" Then
|
|
||||||
sExisted = Right (sExisted, Len (sExisted) - 2)
|
|
||||||
If InStr (sExisted, ",") > 0 Then
|
|
||||||
sExisted = "Spreadsheets " & sExisted & " exist. Overwrite?"
|
|
||||||
Else
|
|
||||||
sExisted = "Spreadsheet " & sExisted & " exists. Overwrite?"
|
|
||||||
End If
|
|
||||||
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
||||||
If nResult = IDNO Then
|
If nResult = IDNO Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Drops the existing report
|
' Drops the existing report
|
||||||
If oSheets.hasByName (sSheetName & "_ttest") Then
|
oSheets.removeByname (sSheetName & "_ttest")
|
||||||
oSheets.removeByname (sSheetName & "_ttest")
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Reports the paired T-test.
|
' Reports the paired T-test.
|
||||||
subReportPairedTTest (ThisComponent, oRange1, oRange2)
|
subReportPairedTTest (ThisComponent, mRanges (0), mRanges (1))
|
||||||
|
|
||||||
' Makes the report sheet active.
|
' Makes the report sheet active.
|
||||||
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
@ -1,4 +1,4 @@
|
|||||||
' _3ITTest: The macros to for generating the report of independent T-Test
|
' 3ITTest: The macros to for generating the report of independent T-Test
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-24
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-24
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
@ -6,127 +6,27 @@ Option Explicit
|
|||||||
' subRunIndependentTTest: Runs the independent T-test.
|
' subRunIndependentTTest: Runs the independent T-test.
|
||||||
Sub subRunIndependentTTest As Object
|
Sub subRunIndependentTTest As Object
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim mLabels () As String, nI As Integer, mSelected (0) As Integer
|
Dim oSheets As Object, sSheetName As String
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oSheet As Object, mRanges As Object
|
||||||
Dim oTextModel As Object, oListModel1 As Object, oListModel2 As Object
|
Dim sExisted As String, nResult As Integer
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim nColumn As Integer, oRange1 As Object, oRange2 As Object
|
|
||||||
Dim oSheets As Object, sSheetName As String, sExisted As String
|
|
||||||
Dim oSheet As Object
|
|
||||||
|
|
||||||
' Asks the user for the data range
|
' Asks the user for the data range
|
||||||
oRange = fnAskDataRange (ThisComponent)
|
oRange = fnAskDataRange (ThisComponent)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
ReDim mLabels (oRange.getColumns.getCount - 1) As String
|
|
||||||
For nI = 0 To oRange.getColumns.getCount - 1
|
|
||||||
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
|
||||||
Next nI
|
|
||||||
|
|
||||||
' Creates a dialog
|
' Specifies the data
|
||||||
oDialogModel = CreateUnoService ( _
|
mRanges = fnSpecifyData (oRange, _
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
"&10.Dlg2SpecData.txtPrompt1.Label3ITTest", _
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
"&11.Dlg2SpecData.txtPrompt2.Label3ITTest")
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
If IsNull (mRanges) Then
|
||||||
oDialogModel.setPropertyValue ("Height", 80)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 2/2: Specify the data")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Group column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptGroup", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel1 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel1.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel1.setPropertyValue ("PositionY", 15)
|
|
||||||
oListModel1.setPropertyValue ("Height", 10)
|
|
||||||
oListModel1.setPropertyValue ("Width", 85)
|
|
||||||
oListModel1.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 0
|
|
||||||
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstGroup", oListModel1)
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 30)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptScore", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel2 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel2.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel2.setPropertyValue ("PositionY", 40)
|
|
||||||
oListModel2.setPropertyValue ("Height", 10)
|
|
||||||
oListModel2.setPropertyValue ("Width", 85)
|
|
||||||
oListModel2.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 1
|
|
||||||
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstScore", oListModel2)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oButtonModel.setPropertyValue ("DefaultButton", True)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
|
||||||
oDialog.dispose
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If nResult = 0 Then
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange1 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange2 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
|
|
||||||
' Checks the existing report
|
' Checks the existing report
|
||||||
oSheets = ThisComponent.getSheets
|
oSheets = ThisComponent.getSheets
|
||||||
sSheetName = oRange1.getSpreadsheet.getName
|
sSheetName = oRange.getSpreadsheet.getName
|
||||||
sExisted = ""
|
sExisted = ""
|
||||||
If oSheets.hasByName (sSheetName & "_ttest") Then
|
If oSheets.hasByName (sSheetName & "_ttest") Then
|
||||||
sExisted = sExisted & ", """ & sSheetName & "_ttest"""
|
sExisted = sExisted & ", """ & sSheetName & "_ttest"""
|
||||||
@ -145,7 +45,6 @@ Sub subRunIndependentTTest As Object
|
|||||||
If nResult = IDNO Then
|
If nResult = IDNO Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Drops the existing report
|
' Drops the existing report
|
||||||
If oSheets.hasByName (sSheetName & "_ttest") Then
|
If oSheets.hasByName (sSheetName & "_ttest") Then
|
||||||
oSheets.removeByname (sSheetName & "_ttest")
|
oSheets.removeByname (sSheetName & "_ttest")
|
||||||
@ -156,7 +55,7 @@ Sub subRunIndependentTTest As Object
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
' Reports the independent T-test.
|
' Reports the independent T-test.
|
||||||
subReportIndependentTTest (ThisComponent, oRange1, oRange2)
|
subReportIndependentTTest (ThisComponent, mRanges (0), mRanges (1))
|
||||||
|
|
||||||
' Makes the report sheet active.
|
' Makes the report sheet active.
|
||||||
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
oSheet = oSheets.getByName (sSheetName & "_ttest")
|
@ -1,4 +1,4 @@
|
|||||||
' _4ANOVA: The macros to for generating the report of ANOVA (Analyze of Variances)
|
' 4ANOVA: The macros to for generating the report of ANOVA (Analyze of Variances)
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-31
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-31
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
@ -6,127 +6,27 @@ Option Explicit
|
|||||||
' subRunANOVA: Runs the ANOVA (Analyze of Variances).
|
' subRunANOVA: Runs the ANOVA (Analyze of Variances).
|
||||||
Sub subRunANOVA As Object
|
Sub subRunANOVA As Object
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim mLabels () As String, nI As Integer, mSelected (0) As Integer
|
Dim oSheets As Object, sSheetName As String
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oSheet As Object, mRanges As Object
|
||||||
Dim oTextModel As Object, oListModel1 As Object, oListModel2 As Object
|
Dim sExisted As String, nResult As Integer
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim nColumn As Integer, oRange1 As Object, oRange2 As Object
|
|
||||||
Dim oSheets As Object, sSheetName As String, sExisted As String
|
|
||||||
Dim oSheet As Object
|
|
||||||
|
|
||||||
' Asks the user for the data range
|
' Asks the user for the data range
|
||||||
oRange = fnAskDataRange (ThisComponent)
|
oRange = fnAskDataRange (ThisComponent)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
ReDim mLabels (oRange.getColumns.getCount - 1) As String
|
|
||||||
For nI = 0 To oRange.getColumns.getCount - 1
|
|
||||||
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
|
||||||
Next nI
|
|
||||||
|
|
||||||
' Creates a dialog
|
' Specifies the data
|
||||||
oDialogModel = CreateUnoService ( _
|
mRanges = fnSpecifyData (oRange, _
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
"&10.Dlg2SpecData.txtPrompt1.Label3ITTest", _
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
"&11.Dlg2SpecData.txtPrompt2.Label3ITTest")
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
If IsNull (mRanges) Then
|
||||||
oDialogModel.setPropertyValue ("Height", 80)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 2/2: Specify the data")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Group column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptGroup", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel1 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel1.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel1.setPropertyValue ("PositionY", 15)
|
|
||||||
oListModel1.setPropertyValue ("Height", 10)
|
|
||||||
oListModel1.setPropertyValue ("Width", 85)
|
|
||||||
oListModel1.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 0
|
|
||||||
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstGroup", oListModel1)
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 30)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Score column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptScore", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel2 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel2.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel2.setPropertyValue ("PositionY", 40)
|
|
||||||
oListModel2.setPropertyValue ("Height", 10)
|
|
||||||
oListModel2.setPropertyValue ("Width", 85)
|
|
||||||
oListModel2.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 1
|
|
||||||
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstScore", oListModel2)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oButtonModel.setPropertyValue ("DefaultButton", True)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
|
||||||
oDialog.dispose
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If nResult = 0 Then
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange1 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange2 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
|
|
||||||
' Checks the existing report
|
' Checks the existing report
|
||||||
oSheets = ThisComponent.getSheets
|
oSheets = ThisComponent.getSheets
|
||||||
sSheetName = oRange1.getSpreadsheet.getName
|
sSheetName = oRange.getSpreadsheet.getName
|
||||||
sExisted = ""
|
sExisted = ""
|
||||||
If oSheets.hasByName (sSheetName & "_anova") Then
|
If oSheets.hasByName (sSheetName & "_anova") Then
|
||||||
sExisted = sExisted & ", """ & sSheetName & "_anova"""
|
sExisted = sExisted & ", """ & sSheetName & "_anova"""
|
||||||
@ -145,7 +45,6 @@ Sub subRunANOVA As Object
|
|||||||
If nResult = IDNO Then
|
If nResult = IDNO Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Drops the existing report
|
' Drops the existing report
|
||||||
If oSheets.hasByName (sSheetName & "_anova") Then
|
If oSheets.hasByName (sSheetName & "_anova") Then
|
||||||
oSheets.removeByname (sSheetName & "_anova")
|
oSheets.removeByname (sSheetName & "_anova")
|
||||||
@ -156,7 +55,7 @@ Sub subRunANOVA As Object
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
' Reports the ANOVA (Analyze of Variances)
|
' Reports the ANOVA (Analyze of Variances)
|
||||||
subReportANOVA (ThisComponent, oRange1, oRange2)
|
subReportANOVA (ThisComponent, mRanges (0), mRanges (1))
|
||||||
|
|
||||||
' Makes the report sheet active.
|
' Makes the report sheet active.
|
||||||
oSheet = oSheets.getByName (sSheetName & "_anova")
|
oSheet = oSheets.getByName (sSheetName & "_anova")
|
@ -1,4 +1,4 @@
|
|||||||
' _5Chi2GoF: The macros to for generating the report of Chi-square goodness of fit
|
' 5Chi2GoF: The macros to for generating the report of Chi-square goodness of fit
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-09-05
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-09-05
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
@ -6,151 +6,39 @@ Option Explicit
|
|||||||
' subRunChi2GoodnessOfFit: Runs the chi-square goodness of fit.
|
' subRunChi2GoodnessOfFit: Runs the chi-square goodness of fit.
|
||||||
Sub subRunChi2GoodnessOfFit As Object
|
Sub subRunChi2GoodnessOfFit As Object
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim mLabels () As String, nI As Integer, mSelected (0) As Integer
|
Dim oSheets As Object, sSheetName As String
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oSheet As Object, mRanges As Object
|
||||||
Dim oTextModel As Object, oListModel1 As Object, oListModel2 As Object
|
Dim sExisted As String, nResult As Integer
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim nColumn As Integer, oRange1 As Object, oRange2 As Object
|
|
||||||
Dim oSheets As Object, sSheetName As String, sExisted As String
|
|
||||||
Dim oSheet As Object
|
|
||||||
|
|
||||||
' Asks the user for the data range
|
' Asks the user for the data range
|
||||||
oRange = fnAskDataRange (ThisComponent)
|
oRange = fnAskDataRange (ThisComponent)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
ReDim mLabels (oRange.getColumns.getCount - 1) As String
|
|
||||||
For nI = 0 To oRange.getColumns.getCount - 1
|
|
||||||
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
|
||||||
Next nI
|
|
||||||
|
|
||||||
' Creates a dialog
|
' Specifies the data
|
||||||
oDialogModel = CreateUnoService ( _
|
mRanges = fnSpecifyData (oRange, _
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
"&12.Dlg2SpecData.txtPrompt1.Label5Chi2GoF", _
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
"&13.Dlg2SpecData.txtPrompt2.Label5Chi2GoF")
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
If IsNull (mRanges) Then
|
||||||
oDialogModel.setPropertyValue ("Height", 80)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 2/2: Specify the data")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Group (column) column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptGroup", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel1 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel1.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel1.setPropertyValue ("PositionY", 15)
|
|
||||||
oListModel1.setPropertyValue ("Height", 10)
|
|
||||||
oListModel1.setPropertyValue ("Width", 85)
|
|
||||||
oListModel1.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 0
|
|
||||||
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstGroup", oListModel1)
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 30)
|
|
||||||
oTextModel.setPropertyValue ("Height", 10)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", "Event (row) column:")
|
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPromptScore", oTextModel)
|
|
||||||
|
|
||||||
' Adds the drop down list
|
|
||||||
oListModel2 = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlListBoxModel")
|
|
||||||
oListModel2.setPropertyValue ("PositionX", 5)
|
|
||||||
oListModel2.setPropertyValue ("PositionY", 40)
|
|
||||||
oListModel2.setPropertyValue ("Height", 10)
|
|
||||||
oListModel2.setPropertyValue ("Width", 85)
|
|
||||||
oListModel2.setPropertyValue ("Dropdown", True)
|
|
||||||
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
|
||||||
mSelected (0) = 1
|
|
||||||
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
|
||||||
oDialogModel.insertByName ("lstScore", oListModel2)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 60)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oButtonModel.setPropertyValue ("DefaultButton", True)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
|
||||||
oDialog.dispose
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If nResult = 0 Then
|
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange1 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
|
||||||
oRange2 = oRange.getCellRangeByPosition ( _
|
|
||||||
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
|
||||||
|
|
||||||
' Checks the existing report
|
' Checks the existing report
|
||||||
oSheets = ThisComponent.getSheets
|
oSheets = ThisComponent.getSheets
|
||||||
sSheetName = oRange1.getSpreadsheet.getName
|
sSheetName = oRange.getSpreadsheet.getName
|
||||||
sExisted = ""
|
|
||||||
If oSheets.hasByName (sSheetName & "_chi2") Then
|
If oSheets.hasByName (sSheetName & "_chi2") Then
|
||||||
sExisted = sExisted & ", """ & sSheetName & "_chi2"""
|
sExisted = "Spreadsheet """ & sSheetName & "_chi2"" exists. Overwrite?"
|
||||||
End If
|
|
||||||
If sExisted <> "" Then
|
|
||||||
sExisted = Right (sExisted, Len (sExisted) - 2)
|
|
||||||
If InStr (sExisted, ",") > 0 Then
|
|
||||||
sExisted = "Spreadsheets " & sExisted & " exist. Overwrite?"
|
|
||||||
Else
|
|
||||||
sExisted = "Spreadsheet " & sExisted & " exists. Overwrite?"
|
|
||||||
End If
|
|
||||||
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
nResult = MsgBox(sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION)
|
||||||
If nResult = IDNO Then
|
If nResult = IDNO Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Drops the existing report
|
' Drops the existing report
|
||||||
If oSheets.hasByName (sSheetName & "_chi2") Then
|
oSheets.removeByname (sSheetName & "_chi2")
|
||||||
oSheets.removeByname (sSheetName & "_chi2")
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Reports the chi-square goodness of fit
|
' Reports the chi-square goodness of fit
|
||||||
subReportChi2GoodnessOfFit (ThisComponent, oRange1, oRange2)
|
subReportChi2GoodnessOfFit (ThisComponent, mRanges (0), mRanges (1))
|
||||||
|
|
||||||
' Makes the report sheet active.
|
' Makes the report sheet active.
|
||||||
oSheet = oSheets.getByName (sSheetName & "_chi2")
|
oSheet = oSheets.getByName (sSheetName & "_chi2")
|
@ -1,23 +1,12 @@
|
|||||||
' _0Main: The main module for the statistics macros
|
' 9Tools: The tool macros
|
||||||
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10
|
' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
|
|
||||||
' subMain: The main program
|
Sub subTest
|
||||||
Sub subMain
|
|
||||||
BasicLibraries.loadLibrary "XrayTool"
|
BasicLibraries.loadLibrary "XrayTool"
|
||||||
|
|
||||||
subRunCorrelation
|
MsgBox fnFormatString ("abc % def", Array ("ghi"))
|
||||||
'subRunPairedTTest
|
|
||||||
'subRunIndependentTTest
|
|
||||||
'subRunAnova
|
|
||||||
'subRunChi2GoodnessOfFit
|
|
||||||
'subTestCorrelation
|
|
||||||
'subTestPairedTTest
|
|
||||||
'subTestIndependentTTest
|
|
||||||
'subTestANOVA
|
|
||||||
'subTestChi2GoodnessOfFit
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
' fnCheckRangeName: Checks the range name and returns the range when
|
' fnCheckRangeName: Checks the range name and returns the range when
|
||||||
@ -100,51 +89,56 @@ Function fnFindStatsTestDocument As Object
|
|||||||
Loop
|
Loop
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
' fnSpecifyData: Specifies the data
|
||||||
|
Function fnSpecifyData (oRange As Object, sPrompt1 As String, sPrompt2 As String) As Object
|
||||||
|
Dim mLabels (oRange.getColumns.getCount - 1) As String
|
||||||
|
Dim nI As Integer, mSelected (0) As Integer
|
||||||
|
Dim oDialog As Object, oTextModel As Object
|
||||||
|
Dim oListModel1 As object, oListModel2 As Object
|
||||||
|
Dim nResult As Integer, nColumn As Integer, mRanges (1) As Object
|
||||||
|
|
||||||
|
For nI = 0 To oRange.getColumns.getCount - 1
|
||||||
|
mLabels (nI) = oRange.getCellByPosition (nI, 0).getString
|
||||||
|
Next nI
|
||||||
|
|
||||||
|
' Runs the dialog
|
||||||
|
oDialog = CreateUnoDialog (DialogLibraries.Stats.Dlg2SpecData)
|
||||||
|
oTextModel = oDialog.getControl ("txtPrompt1").getModel
|
||||||
|
oTextModel.setPropertyValue ("Label", sPrompt1)
|
||||||
|
oListModel1 = oDialog.getControl ("lstData1").getModel
|
||||||
|
oListModel1.setPropertyValue ("StringItemList", mLabels)
|
||||||
|
mSelected (0) = 0
|
||||||
|
oListModel1.setPropertyValue ("SelectedItems", mSelected)
|
||||||
|
oTextModel = oDialog.getControl ("txtPrompt2").getModel
|
||||||
|
oTextModel.setPropertyValue ("Label", sPrompt2)
|
||||||
|
oListModel2 = oDialog.getControl ("lstData2").getModel
|
||||||
|
oListModel2.setPropertyValue ("StringItemList", mLabels)
|
||||||
|
mSelected (0) = 1
|
||||||
|
oListModel2.setPropertyValue ("SelectedItems", mSelected)
|
||||||
|
|
||||||
|
nResult = oDialog.execute
|
||||||
|
oDialog.dispose
|
||||||
|
|
||||||
|
' Cancelled
|
||||||
|
If nResult = 0 Then
|
||||||
|
Exit Function
|
||||||
|
End If
|
||||||
|
|
||||||
|
nColumn = oListModel1.getPropertyValue ("SelectedItems") (0)
|
||||||
|
mRanges (0) = oRange.getCellRangeByPosition ( _
|
||||||
|
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
||||||
|
nColumn = oListModel2.getPropertyValue ("SelectedItems") (0)
|
||||||
|
mRanges (1) = oRange.getCellRangeByPosition ( _
|
||||||
|
nColumn, 0, nColumn, oRange.getRows.getCount - 1)
|
||||||
|
fnSpecifyData = mRanges
|
||||||
|
End Function
|
||||||
|
|
||||||
' fnAskDataRange: Asks the user for the data range, or null when
|
' fnAskDataRange: Asks the user for the data range, or null when
|
||||||
' the user cancelled
|
' the user cancelled
|
||||||
Function fnAskDataRange (oDoc As Object) As Object
|
Function fnAskDataRange (oDoc As Object) As Object
|
||||||
Dim oRange As Object, sPrompt As String, sCellsData As String
|
|
||||||
|
|
||||||
oRange = fnFindActiveDataRange (oDoc)
|
|
||||||
If IsNull (oRange) Then
|
|
||||||
sCellsData = ""
|
|
||||||
Else
|
|
||||||
sCellsData = oRange.getPropertyValue ("AbsoluteName")
|
|
||||||
End If
|
|
||||||
sPrompt = "Cells with the data:"
|
|
||||||
|
|
||||||
' Loop until we get good answer
|
|
||||||
Do While sPrompt <> ""
|
|
||||||
sCellsData = InputBox (sPrompt, "Step 1/2: Select the data range", sCellsData)
|
|
||||||
|
|
||||||
' Cancelled
|
|
||||||
If sCellsData = "" Then
|
|
||||||
Exit Function
|
|
||||||
End If
|
|
||||||
|
|
||||||
oRange = fnCheckRangeName (oDoc, sCellsData)
|
|
||||||
If IsNull (oRange) Then
|
|
||||||
sPrompt = "The range """ & sCellsData & """ does not exist."
|
|
||||||
Else
|
|
||||||
If oRange.getRows.getCount < 2 Or oRange.getColumns.getCount < 2 Then
|
|
||||||
sPrompt = "The range """ & sCellsData & """ is too small (at least 2×2)."
|
|
||||||
Else
|
|
||||||
sPrompt = ""
|
|
||||||
oDoc.getCurrentController.select (oRange)
|
|
||||||
fnAskDataRange = oRange
|
|
||||||
Exit Function
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Loop
|
|
||||||
End Function
|
|
||||||
|
|
||||||
' fnAskDataRange2: Asks the user for the data range, or null when
|
|
||||||
' the user cancelled
|
|
||||||
Function fnAskDataRange2 (oDoc As Object) As Object
|
|
||||||
Dim oRange As Object
|
Dim oRange As Object
|
||||||
Dim oDialogModel As Object, oDialog As Object, nResult As Integer
|
Dim oDialog As Object, nResult As Integer
|
||||||
Dim oTextModel As Object, oEditModel As Object
|
Dim oTextModel As Object, oEditModel As Object
|
||||||
Dim oButtonModel As Object
|
|
||||||
Dim sPrompt As String, sCellsData As String
|
Dim sPrompt As String, sCellsData As String
|
||||||
|
|
||||||
oRange = fnFindActiveDataRange (oDoc)
|
oRange = fnFindActiveDataRange (oDoc)
|
||||||
@ -153,66 +147,17 @@ Function fnAskDataRange2 (oDoc As Object) As Object
|
|||||||
Else
|
Else
|
||||||
sCellsData = oRange.getPropertyValue ("AbsoluteName")
|
sCellsData = oRange.getPropertyValue ("AbsoluteName")
|
||||||
End If
|
End If
|
||||||
sPrompt = "Cells with the data:"
|
sPrompt = "&27.Dlg1AskRange.txtPrompt.Label"
|
||||||
|
|
||||||
' Loop until we finds good data
|
' Loop until we finds good data
|
||||||
Do While sPrompt <> ""
|
Do While sPrompt <> ""
|
||||||
' Creates a dialog
|
' Runs the dialog
|
||||||
oDialogModel = CreateUnoService ( _
|
oDialog = CreateUnoDialog (DialogLibraries.Stats.Dlg1AskRange)
|
||||||
"com.sun.star.awt.UnoControlDialogModel")
|
oTextModel = oDialog.getControl ("txtPrompt").getModel
|
||||||
oDialogModel.setPropertyValue ("PositionX", 200)
|
|
||||||
oDialogModel.setPropertyValue ("PositionY", 200)
|
|
||||||
oDialogModel.setPropertyValue ("Height", 65)
|
|
||||||
oDialogModel.setPropertyValue ("Width", 95)
|
|
||||||
oDialogModel.setPropertyValue ("Title", "Step 1/2: Select the data range")
|
|
||||||
|
|
||||||
' Adds the prompt.
|
|
||||||
oTextModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlFixedTextModel")
|
|
||||||
oTextModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oTextModel.setPropertyValue ("PositionY", 5)
|
|
||||||
oTextModel.setPropertyValue ("Height", 15)
|
|
||||||
oTextModel.setPropertyValue ("Width", 85)
|
|
||||||
oTextModel.setPropertyValue ("Label", sPrompt)
|
oTextModel.setPropertyValue ("Label", sPrompt)
|
||||||
oTextModel.setPropertyValue ("MultiLine", True)
|
oEditModel = oDialog.getControl ("edtCellsData").getModel
|
||||||
oTextModel.setPropertyValue ("TabIndex", 1)
|
|
||||||
oDialogModel.insertByName ("txtPrompt", oTextModel)
|
|
||||||
|
|
||||||
' Adds the text input.
|
|
||||||
oEditModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlEditModel")
|
|
||||||
oEditModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oEditModel.setPropertyValue ("PositionY", 25)
|
|
||||||
oEditModel.setPropertyValue ("Height", 15)
|
|
||||||
oEditModel.setPropertyValue ("Width", 85)
|
|
||||||
oEditModel.setPropertyValue ("Text", sCellsData)
|
oEditModel.setPropertyValue ("Text", sCellsData)
|
||||||
oDialogModel.insertByName ("edtCellsData", oEditModel)
|
|
||||||
|
|
||||||
' Adds the buttons.
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 5)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 45)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.CANCEL)
|
|
||||||
oDialogModel.insertByName ("btnClose", oButtonModel)
|
|
||||||
|
|
||||||
oButtonModel = oDialogModel.createInstance ( _
|
|
||||||
"com.sun.star.awt.UnoControlButtonModel")
|
|
||||||
oButtonModel.setPropertyValue ("PositionX", 50)
|
|
||||||
oButtonModel.setPropertyValue ("PositionY", 45)
|
|
||||||
oButtonModel.setPropertyValue ("Height", 15)
|
|
||||||
oButtonModel.setPropertyValue ("Width", 40)
|
|
||||||
oButtonModel.setPropertyValue ("PushButtonType", _
|
|
||||||
com.sun.star.awt.PushButtonType.OK)
|
|
||||||
oDialogModel.insertByName ("btnOK", oButtonModel)
|
|
||||||
|
|
||||||
' Adds the dialog model to the control and runs it.
|
|
||||||
oDialog = CreateUnoService ("com.sun.star.awt.UnoControlDialog")
|
|
||||||
oDialog.setModel (oDialogModel)
|
|
||||||
oDialog.setVisible (True)
|
|
||||||
nResult = oDialog.execute
|
nResult = oDialog.execute
|
||||||
oDialog.dispose
|
oDialog.dispose
|
||||||
|
|
||||||
@ -223,14 +168,14 @@ Function fnAskDataRange2 (oDoc As Object) As Object
|
|||||||
|
|
||||||
sCellsData = oEditModel.getPropertyValue ("Text")
|
sCellsData = oEditModel.getPropertyValue ("Text")
|
||||||
If sCellsData = "" Then
|
If sCellsData = "" Then
|
||||||
sPrompt = "Cells with the data:"
|
sPrompt = "&27.Dlg1AskRange.txtPrompt.Label"
|
||||||
Else
|
Else
|
||||||
oRange = fnCheckRangeName (oDoc, sCellsData)
|
oRange = fnCheckRangeName (oDoc, sCellsData)
|
||||||
If IsNull (oRange) Then
|
If IsNull (oRange) Then
|
||||||
sPrompt = "The range """ & sCellsData & """ does not exist."
|
sPrompt = "&35.Dlg1AskRange.txtPrompt.LabelNotExists"
|
||||||
Else
|
Else
|
||||||
If oRange.getRows.getCount < 2 Or oRange.getColumns.getCount < 2 Then
|
If oRange.getRows.getCount < 2 Or oRange.getColumns.getCount < 2 Then
|
||||||
sPrompt = "The range """ & sCellsData & """ is too small (at least 2×2)."
|
sPrompt = "&36.Dlg1AskRange.txtPrompt.LabelTooSmall"
|
||||||
Else
|
Else
|
||||||
sPrompt = ""
|
sPrompt = ""
|
||||||
oDoc.getCurrentController.select (oRange)
|
oDoc.getCurrentController.select (oRange)
|
Loading…
Reference in New Issue
Block a user