From b16a28f5776226a01026d3f3ae18ca1e44595308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 9 Sep 2016 23:21:50 +0800 Subject: [PATCH] Restructured the project directory: Moved the sources into a subdirectory. Added build.xml, LICENSE, VERSION for distribution. --- LICENSE | 611 +++++++++++ 1CorRel.vb => StatTool/1CorRel.vb | 0 2PTTest.vb => StatTool/2PTTest.vb | 0 3ITTest.vb => StatTool/3ITTest.vb | 0 4ANOVA.vb => StatTool/4ANOVA.vb | 0 5Chi2GoF.vb => StatTool/5Chi2GoF.vb | 0 9Utils.vb => StatTool/9Utils.vb | 0 VERSION | 1 + build.xml | 62 ++ oxt/Addons.xcu | 103 ++ oxt/META-INF/manifest.xml | 8 + oxt/StatTool/1CorRel.xba | 334 ++++++ oxt/StatTool/2PTTest.xba | 648 +++++++++++ oxt/StatTool/3ITTest.xba | 811 ++++++++++++++ oxt/StatTool/4ANOVA.xba | 1075 +++++++++++++++++++ oxt/StatTool/5Chi2GoF.xba | 865 +++++++++++++++ oxt/StatTool/9Utils.xba | 225 ++++ oxt/StatTool/DialogStrings_en_US.default | 0 oxt/StatTool/DialogStrings_en_US.properties | 24 + oxt/StatTool/DialogStrings_zh_CN.properties | 24 + oxt/StatTool/DialogStrings_zh_TW.properties | 24 + oxt/StatTool/Dlg1AskRange.xdl | 10 + oxt/StatTool/Dlg2SpecData.xdl | 12 + oxt/StatTool/dialog.xlb | 6 + oxt/StatTool/script.xlb | 10 + oxt/description.xml | 26 + oxt/pkg-desc/pkg-description.txt | 4 + oxt/pkg-desc/pkg-description.zh-CN.txt | 4 + oxt/pkg-desc/pkg-description.zh-TW.txt | 4 + oxt/registration/LICENSE | 611 +++++++++++ 30 files changed, 5502 insertions(+) create mode 100644 LICENSE rename 1CorRel.vb => StatTool/1CorRel.vb (100%) rename 2PTTest.vb => StatTool/2PTTest.vb (100%) rename 3ITTest.vb => StatTool/3ITTest.vb (100%) rename 4ANOVA.vb => StatTool/4ANOVA.vb (100%) rename 5Chi2GoF.vb => StatTool/5Chi2GoF.vb (100%) rename 9Utils.vb => StatTool/9Utils.vb (100%) create mode 100644 VERSION create mode 100644 build.xml create mode 100644 oxt/Addons.xcu create mode 100644 oxt/META-INF/manifest.xml create mode 100644 oxt/StatTool/1CorRel.xba create mode 100644 oxt/StatTool/2PTTest.xba create mode 100644 oxt/StatTool/3ITTest.xba create mode 100644 oxt/StatTool/4ANOVA.xba create mode 100644 oxt/StatTool/5Chi2GoF.xba create mode 100644 oxt/StatTool/9Utils.xba create mode 100644 oxt/StatTool/DialogStrings_en_US.default create mode 100644 oxt/StatTool/DialogStrings_en_US.properties create mode 100644 oxt/StatTool/DialogStrings_zh_CN.properties create mode 100644 oxt/StatTool/DialogStrings_zh_TW.properties create mode 100644 oxt/StatTool/Dlg1AskRange.xdl create mode 100644 oxt/StatTool/Dlg2SpecData.xdl create mode 100644 oxt/StatTool/dialog.xlb create mode 100644 oxt/StatTool/script.xlb create mode 100644 oxt/description.xml create mode 100644 oxt/pkg-desc/pkg-description.txt create mode 100644 oxt/pkg-desc/pkg-description.zh-CN.txt create mode 100644 oxt/pkg-desc/pkg-description.zh-TW.txt create mode 100644 oxt/registration/LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3007bca --- /dev/null +++ b/LICENSE @@ -0,0 +1,611 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +APACHE HTTP SERVER SUBCOMPONENTS: + +The Apache HTTP Server includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +For the mod_mime_magic component: + +/* + * mod_mime_magic: MIME type lookup via file magic numbers + * Copyright (c) 1996-1997 Cisco Systems, Inc. + * + * This software was submitted by Cisco Systems to the Apache Group in July + * 1997. Future revisions and derivatives of this source code must + * acknowledge Cisco Systems as the original contributor of this module. + * All other licensing and usage conditions are those of the Apache Group. + * + * Some of this code is derived from the free version of the file command + * originally posted to comp.sources.unix. Copyright info for that program + * is included below as required. + * --------------------------------------------------------------------------- + * - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin. + * + * This software is not subject to any license of the American Telephone and + * Telegraph Company or of the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on any + * computer system, and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, credits + * must appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users ever read + * sources, credits must appear in the documentation. + * + * 4. This notice may not be removed or altered. + * ------------------------------------------------------------------------- + * + */ + + +For the modules\mappers\mod_imagemap.c component: + + "macmartinized" polygon code copyright 1992 by Eric Haines, erich@eye.com + +For the server\util_md5.c component: + +/************************************************************************ + * NCSA HTTPd Server + * Software Development Group + * National Center for Supercomputing Applications + * University of Illinois at Urbana-Champaign + * 605 E. Springfield, Champaign, IL 61820 + * httpd@ncsa.uiuc.edu + * + * Copyright (C) 1995, Board of Trustees of the University of Illinois + * + ************************************************************************ + * + * md5.c: NCSA HTTPd code which uses the md5c.c RSA Code + * + * Original Code Copyright (C) 1994, Jeff Hostetler, Spyglass, Inc. + * Portions of Content-MD5 code Copyright (C) 1993, 1994 by Carnegie Mellon + * University (see Copyright below). + * Portions of Content-MD5 code Copyright (C) 1991 Bell Communications + * Research, Inc. (Bellcore) (see Copyright below). + * Portions extracted from mpack, John G. Myers - jgm+@cmu.edu + * Content-MD5 Code contributed by Martin Hamilton (martin@net.lut.ac.uk) + * + */ + + +/* these portions extracted from mpack, John G. Myers - jgm+@cmu.edu */ +/* (C) Copyright 1993,1994 by Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Carnegie + * Mellon University not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. Carnegie Mellon University makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) + * + * Permission to use, copy, modify, and distribute this material + * for any purpose and without fee is hereby granted, provided + * that the above copyright notice and this permission notice + * appear in all copies, and that the name of Bellcore not be + * used in advertising or publicity pertaining to this + * material without the specific, prior written permission + * of an authorized representative of Bellcore. BELLCORE + * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY + * OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", + * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. + */ + +For the srclib\apr\include\apr_md5.h component: +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +For the srclib\apr\passwd\apr_md5.c component: + +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ +/* + * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0 + * MD5 crypt() function, which is licenced as follows: + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + */ + +For the srclib\apr-util\crypto\apr_md4.c component: + + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +For the srclib\apr-util\include\apr_md4.h component: + + * + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + + +For the srclib\apr-util\test\testmd4.c component: + + * + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All + * rights reserved. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +For the srclib\apr-util\xml\expat\conftools\install-sh component: + +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# + +For the srclib\pcre\install-sh component: + +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. + +For the pcre component: + +PCRE LICENCE +------------ + +PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + +Release 5 of PCRE is distributed under the terms of the "BSD" licence, as +specified below. The documentation for PCRE, supplied in the "doc" +directory, is distributed under the same terms as the software itself. + +Written by: Philip Hazel + +University of Cambridge Computing Service, +Cambridge, England. Phone: +44 1223 334714. + +Copyright (c) 1997-2004 University of Cambridge +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +End PCRE LICENCE + + +For the test\zb.c component: + +/* ZeusBench V1.01 + =============== + +This program is Copyright (C) Zeus Technology Limited 1996. + +This program may be used and copied freely providing this copyright notice +is not removed. + +This software is provided "as is" and any express or implied waranties, +including but not limited to, the implied warranties of merchantability and +fitness for a particular purpose are disclaimed. In no event shall +Zeus Technology Ltd. be liable for any direct, indirect, incidental, special, +exemplary, or consequential damaged (including, but not limited to, +procurement of substitute good or services; loss of use, data, or profits; +or business interruption) however caused and on theory of liability. Whether +in contract, strict liability or tort (including negligence or otherwise) +arising in any way out of the use of this software, even if advised of the +possibility of such damage. + + Written by Adam Twiss (adam@zeus.co.uk). March 1996 + +Thanks to the following people for their input: + Mike Belshe (mbelshe@netscape.com) + Michael Campanella (campanella@stevms.enet.dec.com) + +*/ + +For the expat xml parser component: + +Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + and Clark Cooper + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +==================================================================== diff --git a/1CorRel.vb b/StatTool/1CorRel.vb similarity index 100% rename from 1CorRel.vb rename to StatTool/1CorRel.vb diff --git a/2PTTest.vb b/StatTool/2PTTest.vb similarity index 100% rename from 2PTTest.vb rename to StatTool/2PTTest.vb diff --git a/3ITTest.vb b/StatTool/3ITTest.vb similarity index 100% rename from 3ITTest.vb rename to StatTool/3ITTest.vb diff --git a/4ANOVA.vb b/StatTool/4ANOVA.vb similarity index 100% rename from 4ANOVA.vb rename to StatTool/4ANOVA.vb diff --git a/5Chi2GoF.vb b/StatTool/5Chi2GoF.vb similarity index 100% rename from 5Chi2GoF.vb rename to StatTool/5Chi2GoF.vb diff --git a/9Utils.vb b/StatTool/9Utils.vb similarity index 100% rename from 9Utils.vb rename to StatTool/9Utils.vb diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..e840275 --- /dev/null +++ b/build.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oxt/Addons.xcu b/oxt/Addons.xcu new file mode 100644 index 0000000..42aed0f --- /dev/null +++ b/oxt/Addons.xcu @@ -0,0 +1,103 @@ + + + + + + + com.sun.star.sheet.SpreadsheetDocument + + + ~Statistics + 統計(~S) + 统计(~S) + + + + + + + + vnd.sun.star.script:StatTool.1CorRel.subRunCorrelation?language=Basic&location=application + + + Pearson’s cor~relation coefficient + 皮爾森相關係數(~R) + 皮尔森相关系数(~R) + + + _self + + + + + + + + vnd.sun.star.script:StatTool.2PTTest.subRunPairedTTest?language=Basic&location=application + + + ~Paired-samples T-test + 相依樣本T檢定(~P) + 相依样本T检定(~P) + + + _self + + + + + + + + vnd.sun.star.script:StatTool.3ITTest.subRunIndependentTTest?language=Basic&location=application + + + ~Independent samples T-test + 獨立樣本T檢定(~I) + 独立样本T检定(~I) + + + _self + + + + + + + + vnd.sun.star.script:StatTool.4ANOVA.subRunANOVA?language=Basic&location=application + + + One-way ~ANOVA + 單因子變異數分析(~A) + 单因子变异数分析(~A) + + + _self + + + + + + + + vnd.sun.star.script:StatTool.5Chi2GoF.subRunChi2GoodnessOfFit?language=Basic&location=application + + + ~Chi-square goodness of fit + 卡方檢定:百分比同質性考驗(~C) + 卡方检定:百分比同质性考验(~C) + + + _self + + + + + + + diff --git a/oxt/META-INF/manifest.xml b/oxt/META-INF/manifest.xml new file mode 100644 index 0000000..15b3ed9 --- /dev/null +++ b/oxt/META-INF/manifest.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/oxt/StatTool/1CorRel.xba b/oxt/StatTool/1CorRel.xba new file mode 100644 index 0000000..3ce6334 --- /dev/null +++ b/oxt/StatTool/1CorRel.xba @@ -0,0 +1,334 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 1CorRel: The macros to for generating the report of the Pearson’s correlation coefficient +' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10 + +Option Explicit + +' subRunCorrelation: Runs the Pearson’s correlation coefficient. +Sub subRunCorrelation As Object + Dim oRange As Object + Dim oSheets As Object, sSheetName As String + Dim oSheet As Object, mRanges As Object + Dim sExisted As String, nResult As Integer + + DialogLibraries.loadLibrary "StatTool" + + ' Asks the user for the data range + oRange = fnAskDataRange (ThisComponent) + If IsNull (oRange) Then + Exit Sub + End If + + ' Specifies the data + mRanges = fnSpecifyData (oRange, _ + "&3.Dlg2SpecData.txtPrompt1.Label1CorRel", _ + "&6.Dlg2SpecData.txtPrompt2.Label1CorRel") + If IsNull (mRanges) Then + Exit Sub + End If + + ' Checks the existing report + oSheets = ThisComponent.getSheets + sSheetName = oRange.getSpreadsheet.getName + If oSheets.hasByName (sSheetName & "_correl") Then + sExisted = "Spreadsheet """ & sSheetName & "_correl"" exists. Overwrite?" + nResult = MsgBox (sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION) + If nResult = IDNO Then + Exit Sub + End If + ' Drops the existing report + oSheets.removeByname (sSheetName & "_correl") + End If + + ' Reports the paired T-test. + subReportCorrelation (ThisComponent, mRanges (0), mRanges (1)) + oSheet = oSheets.getByName (sSheetName & "_correl") + + ' Adds an X-Y diagram. + subAddChart (oSheet, mRanges (0), mRanges (1)) + + ' Makes the report sheet active. + ThisComponent.getCurrentController.setActiveSheet (oSheet) +End Sub + +' subAddChart: Adds a chart for the data +Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object) + Dim oCharts As Object, oChart As Object + Dim oChartDoc As Object, oDiagram As Object + Dim aPos As New com.sun.star.awt.Rectangle + Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress + Dim sTitle As String + Dim oProvider As Object, oData As Object + Dim sRange As String, mData () As Object + + ' Adds the chart + With aPos + .X = 0 + .Y = 3510 + .Width = 10000 + .Height = 10000 + End With + mAddrs (0) = oDataXRange.getRangeAddress + mAddrs (1) = oDataYRange.getRangeAddress + oCharts = oSheet.getCharts + oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False) + oChart = oCharts.getByName (oSheet.getName) + oChartDoc = oChart.getEmbeddedObject + + BasicLibraries.loadLibrary "XrayTool" + oDiagram = oChartDoc.createInstance ( _ + "com.sun.star.chart.XYDiagram") + oDiagram.setPropertyValue ("Lines", False) + oDiagram.setPropertyValue ("HasXAxisGrid", False) + oDiagram.setPropertyValue ("HasYAxisGrid", False) + sTitle = oDataXRange.getCellByPosition (0, 0).getString + oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle) + sTitle = oDataYRange.getCellByPosition (0, 0).getString + oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle) + oDiagram.getXAxis.setPropertyValue ("Min", 0) + oDiagram.getYAxis.setPropertyValue ("Min", 0) + oChartDoc.setDiagram (oDiagram) + + oProvider = oChartDoc.getDataProvider + mData = oChartDoc.getDataSequences + sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + mData (0).setLabel (oData) + sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + oData.Role = "values-x" + mData (0).setValues (oData) + sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + mData (1).setLabel (oData) + sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + oData.Role = "values-y" + mData (1).setValues (oData) + + oChartDoc.setPropertyValue ("HasLegend", False) +End Sub + +' subReportCorrelation: Reports the Pearson’s correlation coefficient +Sub subReportCorrelation (oDoc As Object, oDataXRange As Object, oDataYRange As Object) + Dim oSheets As Object, sSheetName As String + Dim mNames () As String, nI As Integer, nSheetIndex As Integer + Dim oSheet As Object, oColumns As Object, nRow As Integer + Dim oCell As Object, oCells As Object, oCursor As Object + Dim nN As Integer, sFormula As String + Dim sNotes As String, nPos As Integer + Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer + Dim aBorderSingle As New com.sun.star.table.BorderLine + Dim aBorderDouble As New com.sun.star.table.BorderLine + Dim sCellXLabel As String, sCellsXData As String + Dim sCellYLabel As String, sCellsYData As String + Dim sCellN As String, sCellR As String + + oSheets = oDoc.getSheets + sSheetName = oDataXRange.getSpreadsheet.getName + mNames = oSheets.getElementNames + For nI = 0 To UBound (mNames) + If mNames (nI) = sSheetName Then + nSheetIndex = nI + End If + Next nI + oSheets.insertNewByName (sSheetName & "_correl", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_correl") + + nN = oDataXRange.getRows.getCount - 1 + sCellXLabel = fnGetRangeName (oDataXRange.getCellByPosition (0, 0)) + sCellsXData = fnGetRangeName (oDataXRange.getCellRangeByPosition (0, 1, 0, nN)) + sCellYLabel = fnGetRangeName (oDataYRange.getCellByPosition (0, 0)) + sCellsYData = fnGetRangeName (oDataYRange.getCellRangeByPosition (0, 1, 0, nN)) + + ' Obtains the format parameters for the report. + nFormatN = fnQueryFormat (oDoc, "#,##0") + nFormatF = fnQueryFormat (oDoc, "#,###.000") + nFormatP = fnQueryFormat (oDoc, "[<0.01]#.000""**"";[<0.05]#.000""*"";#.000") + + aBorderSingle.OuterLineWidth = 2 + aBorderDouble.OuterLineWidth = 2 + aBorderDouble.InnerLineWidth = 2 + aBorderDouble.LineDistance = 2 + + ' Sets the column widths of the report. + oColumns = oSheet.getColumns + oColumns.getByIndex (0).setPropertyValue ("Width", 3060) + oColumns.getByIndex (1).setPropertyValue ("Width", 3060) + oColumns.getByIndex (2).setPropertyValue ("Width", 2080) + oColumns.getByIndex (3).setPropertyValue ("Width", 2080) + oColumns.getByIndex (4).setPropertyValue ("Width", 2080) + + nRow = -2 + + ' Correlation + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Pearson’s Correlation") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("X") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("Y") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("N") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("r") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=COUNT(" & sCellsXData & ")" + oCell.setFormula (sFormula) + sCellN = fnGetLocalRangeName (oCell) + oCell.setPropertyValue ("NumberFormat", nFormatN) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=CORREL(" & sCellsXData & ";" & sCellsYData & ")" + oCell.setFormula (sFormula) + sCellR = fnGetLocalRangeName (oCell) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=TDIST(" & sCellR & "*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & "))" & ";" & sCellN & "-2;2)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: ρ=0 (the populations of the two groups are irrelavent)." & Chr (10) & _ + "H1: ρ≠0 (the populations of the two groups are relevant) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "ρ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "ρ") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (1, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nRow - 2, 4, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) +End Sub + \ No newline at end of file diff --git a/oxt/StatTool/2PTTest.xba b/oxt/StatTool/2PTTest.xba new file mode 100644 index 0000000..df2b3f3 --- /dev/null +++ b/oxt/StatTool/2PTTest.xba @@ -0,0 +1,648 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 2PTTest: The macros to for generating the report of paired T-Test +' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-11 + +Option Explicit + +' subRunPairedTTest: Runs the paired T-test. +Sub subRunPairedTTest As Object + Dim oRange As Object + Dim oSheets As Object, sSheetName As String + Dim oSheet As Object, mRanges As Object + Dim sExisted As String, nResult As Integer + + DialogLibraries.loadLibrary "StatTool" + + ' Asks the user for the data range + oRange = fnAskDataRange (ThisComponent) + If IsNull (oRange) Then + Exit Sub + End If + + ' Specifies the data + mRanges = fnSpecifyData (oRange, _ + "&3.Dlg2SpecData.txtPrompt1.Label1CorRel", _ + "&6.Dlg2SpecData.txtPrompt2.Label1CorRel") + If IsNull (mRanges) Then + Exit Sub + End If + + ' Checks the existing report + oSheets = ThisComponent.getSheets + sSheetName = oRange.getSpreadsheet.getName + If oSheets.hasByName (sSheetName & "_ttest") Then + sExisted = "Spreadsheet """ & sSheetName & "_ttest"" exists. Overwrite?" + nResult = MsgBox (sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION) + If nResult = IDNO Then + Exit Sub + End If + ' Drops the existing report + oSheets.removeByname (sSheetName & "_ttest") + End If + + ' Reports the paired T-test. + subReportPairedTTest (ThisComponent, mRanges (0), mRanges (1)) + oSheet = oSheets.getByName (sSheetName & "_ttest") + + ' Adds an X-Y diagram. + subAddChart (oSheet, mRanges (0), mRanges (1)) + + ' Makes the report sheet active. + ThisComponent.getCurrentController.setActiveSheet (oSheet) +End Sub + +' subAddChart: Adds a chart for the data +Sub subAddChart (oSheet As Object, oDataXRange As Object, oDataYRange As Object) + Dim oCharts As Object, oChart As Object + Dim oChartDoc As Object, oDiagram As Object + Dim aPos As New com.sun.star.awt.Rectangle + Dim mAddrs (1) As New com.sun.star.table.CellRangeAddress + Dim sTitle As String + Dim oProvider As Object, oData As Object + Dim sRange As String, mData () As Object + + ' Adds the chart + With aPos + .X = 0 + .Y = 10000 + .Width = 10000 + .Height = 10000 + End With + mAddrs (0) = oDataXRange.getRangeAddress + mAddrs (1) = oDataYRange.getRangeAddress + oCharts = oSheet.getCharts + oCharts.addNewByName (oSheet.getName, aPos, mAddrs, True, False) + oChart = oCharts.getByName (oSheet.getName) + oChartDoc = oChart.getEmbeddedObject + + BasicLibraries.loadLibrary "XrayTool" + oDiagram = oChartDoc.createInstance ( _ + "com.sun.star.chart.XYDiagram") + oDiagram.setPropertyValue ("Lines", False) + oDiagram.setPropertyValue ("HasXAxisGrid", False) + oDiagram.setPropertyValue ("HasYAxisGrid", False) + sTitle = oDataXRange.getCellByPosition (0, 0).getString + oDiagram.getXAxisTitle.setPropertyValue ("String", sTitle) + sTitle = oDataYRange.getCellByPosition (0, 0).getString + oDiagram.getYAxisTitle.setPropertyValue ("String", sTitle) + oDiagram.getXAxis.setPropertyValue ("Min", 0) + oDiagram.getYAxis.setPropertyValue ("Min", 0) + oChartDoc.setDiagram (oDiagram) + + oProvider = oChartDoc.getDataProvider + mData = oChartDoc.getDataSequences + sRange = oDataXRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + mData (0).setLabel (oData) + sRange = oDataXRange.getCellRangeByPosition(0, 1, 0, oDataXRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + oData.Role = "values-x" + mData (0).setValues (oData) + sRange = oDataYRange.getCellByPosition(0, 0).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + mData (1).setLabel (oData) + sRange = oDataYRange.getCellRangeByPosition(0, 1, 0, oDataYRange.getRows.getCount - 1).getPropertyValue ("AbsoluteName") + oData = oProvider.createDataSequenceByRangeRepresentation (sRange) + oData.Role = "values-y" + mData (1).setValues (oData) + + oChartDoc.setPropertyValue ("HasLegend", False) +End Sub + +' subReportPairedTTest: Reports the paired T-test +Sub subReportPairedTTest (oDoc As Object, oDataXRange As Object, oDataYRange As Object) + Dim oSheets As Object, sSheetName As String + Dim mNames () As String, nI As Integer, nSheetIndex As Integer + Dim oSheet As Object, oColumns As Object, nRow As Integer + Dim oCell As Object, oCells As Object, oCursor As Object + Dim nN As Integer, sFormula As String + Dim sNotes As String, nPos As Integer + Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer + Dim aBorderSingle As New com.sun.star.table.BorderLine + Dim aBorderDouble As New com.sun.star.table.BorderLine + Dim sCellXLabel As String, sCellsXData As String + Dim sCellXN As String, sCellXMean As String, sCellXS As String + Dim sCellYLabel As String, sCellsYData As String + Dim sCellYN As String, sCellYMean As String, sCellYS As String + Dim sCellN As String, sCellXYS As String, sCellR As String + + oSheets = oDoc.getSheets + sSheetName = oDataXRange.getSpreadsheet.getName + mNames = oSheets.getElementNames + For nI = 0 To UBound (mNames) + If mNames (nI) = sSheetName Then + nSheetIndex = nI + End If + Next nI + oSheets.insertNewByName (sSheetName & "_ttest", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_ttest") + + nN = oDataXRange.getRows.getCount - 1 + sCellXLabel = fnGetRangeName (oDataXRange.getCellByPosition (0, 0)) + sCellsXData = fnGetRangeName (oDataXRange.getCellRangeByPosition (0, 1, 0, nN)) + sCellYLabel = fnGetRangeName (oDataYRange.getCellByPosition (0, 0)) + sCellsYData = fnGetRangeName (oDataYRange.getCellRangeByPosition (0, 1, 0, nN)) + + ' Obtains the format parameters for the report. + nFormatN = fnQueryFormat (oDoc, "#,##0") + nFormatF = fnQueryFormat (oDoc, "#,###.000") + nFormatP = fnQueryFormat (oDoc, "[<0.01]#.000""**"";[<0.05]#.000""*"";#.000") + + aBorderSingle.OuterLineWidth = 2 + aBorderDouble.OuterLineWidth = 2 + aBorderDouble.InnerLineWidth = 2 + aBorderDouble.LineDistance = 2 + + ' Sets the column widths of the report. + oColumns = oSheet.getColumns + oColumns.getByIndex (0).setPropertyValue ("Width", 3060) + oColumns.getByIndex (1).setPropertyValue ("Width", 3060) + oColumns.getByIndex (2).setPropertyValue ("Width", 2080) + oColumns.getByIndex (3).setPropertyValue ("Width", 2080) + oColumns.getByIndex (4).setPropertyValue ("Width", 2080) + + nRow = -2 + ' Group description + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Sample Description") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Sample") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("N") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("X") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("s") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (5, nRow) + oCell.setString ("sX") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + + ' The first group + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=COUNT(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellXN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=AVERAGE(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellXMean = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=STDEV(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellXS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & sCellXS & "/SQRT(" & sCellXN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' The second group + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=COUNT(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellYN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=AVERAGE(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellYMean = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=STDEV(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellYS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & sCellYS & "/SQRT(" & sCellYN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' The difference between the two groups + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=""(""&" & sCellXLabel & "&""-""&" & sCellYLabel & "&"")""" + oCell.setFormula (sFormula) + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & sCellXN + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & sCellXMean & "-" & sCellYMean + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=SQRT(" & sCellXS & "*" & sCellXS & "-2*SUMPRODUCT(" & sCellsXData & ";" & sCellsYData & ")/(" & sCellN & "-1)+2*" & sCellXMean & "*" & sCellYMean & "*" & sCellN & "/(" & sCellN & "-1)+" & sCellYS & "*" & sCellYS & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellXYS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & sCellXYS & "/SQRT(" & sCellN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 3) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 3, 5, nRow - 3) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (0, nRow - 2, 0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow, 5, nRow) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' Correlation + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Pearson’s Correlation") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 3, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("X1") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("X2") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("r") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=CORREL(" & sCellsXData & ";" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellR = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=TDIST(ABS(" & sCellR & ")*SQRT((" & sCellN & "-2)/(1-" & sCellR & "*" & sCellR & "))" & ";" & sCellN & "-2;2)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: ρ=0 (the populations of the two samples are irrelavent)." & Chr (10) & _ + "H1: ρ≠0 (the populations of the two samples are relevant) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 3, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "ρ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (1, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nRow - 2, 3, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 3, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' Paired-samples T-test + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Paired-Samples T-test") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("X1") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("X2") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("t") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("df") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=(" & sCellXMean & "-" & sCellYMean & ")/SQRT((" & sCellXS & "*" & sCellXS & "+" & sCellYS & "*" & sCellYS & "-2*" & sCellR & "*" & sCellXS & "*" & sCellYS & ")/" & sCellN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & sCellN & "-1" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=TTEST(" & sCellsXData & ";" & sCellsYData & ";2;1)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: μ1=μ2 (the populations of the two samples have the same means)." & Chr (10) & _ + "H1: μ1≠μ2 (the populations of the two samples have different means) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "μ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (nPos + 1, sNotes, "μ") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (1, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nRow - 2, 4, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) +End Sub + \ No newline at end of file diff --git a/oxt/StatTool/3ITTest.xba b/oxt/StatTool/3ITTest.xba new file mode 100644 index 0000000..d34fb45 --- /dev/null +++ b/oxt/StatTool/3ITTest.xba @@ -0,0 +1,811 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 3ITTest: The macros to for generating the report of independent T-Test +' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-24 + +Option Explicit + +' subRunIndependentTTest: Runs the independent T-test. +Sub subRunIndependentTTest As Object + Dim oRange As Object + Dim oSheets As Object, sSheetName As String + Dim oSheet As Object, mRanges As Object + Dim sExisted As String, nResult As Integer + + DialogLibraries.loadLibrary "StatTool" + + ' Asks the user for the data range + oRange = fnAskDataRange (ThisComponent) + If IsNull (oRange) Then + Exit Sub + End If + + ' Specifies the data + mRanges = fnSpecifyData (oRange, _ + "&10.Dlg2SpecData.txtPrompt1.Label3ITTest", _ + "&11.Dlg2SpecData.txtPrompt2.Label3ITTest") + If IsNull (mRanges) Then + Exit Sub + End If + + ' Checks the existing report + oSheets = ThisComponent.getSheets + sSheetName = oRange.getSpreadsheet.getName + sExisted = "" + If oSheets.hasByName (sSheetName & "_ttest") Then + sExisted = sExisted & ", """ & sSheetName & "_ttest""" + End If + If oSheets.hasByName (sSheetName & "_ttesttmp") Then + sExisted = sExisted & ", """ & sSheetName & "_ttesttmp""" + 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) + If nResult = IDNO Then + Exit Sub + End If + ' Drops the existing report + If oSheets.hasByName (sSheetName & "_ttest") Then + oSheets.removeByname (sSheetName & "_ttest") + End If + If oSheets.hasByName (sSheetName & "_ttesttmp") Then + oSheets.removeByname (sSheetName & "_ttesttmp") + End If + End If + + ' Reports the independent T-test. + subReportIndependentTTest (ThisComponent, mRanges (0), mRanges (1)) + oSheet = oSheets.getByName (sSheetName & "_ttest") + + ' Makes the report sheet active. + ThisComponent.getCurrentController.setActiveSheet (oSheet) +End Sub + +' subReportIndependentTTest: Reports the independent T-test +Sub subReportIndependentTTest (oDoc As Object, oLabelColumn As Object, oScoreColumn As Object) + Dim oSheets As Object, sSheetName As String + Dim mNames () As String, nI As Integer, nSheetIndex As Integer + Dim oSheet As Object, oColumns As Object, nRow As Integer + Dim oCell As Object, oCells As Object, oCursor As Object, oTempDataRange As Object + Dim nN As Integer, sFormula As String, sSP2 As String + Dim sNotes As String, nPos As Integer + Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer + Dim aBorderSingle As New com.sun.star.table.BorderLine + Dim aBorderDouble As New com.sun.star.table.BorderLine + Dim sCellXLabel As String, sCellsXData As String + Dim sCellXN As String, sCellXMean As String, sCellXS As String + Dim sCellYLabel As String, sCellsYData As String + Dim sCellYN As String, sCellYMean As String, sCellYS As String + Dim sCellF As String, sCellsN As String, sCellN As String + + oSheets = oDoc.getSheets + sSheetName = oLabelColumn.getSpreadsheet.getName + mNames = oSheets.getElementNames + For nI = 0 To UBound (mNames) + If mNames (nI) = sSheetName Then + nSheetIndex = nI + End If + Next nI + + oSheets.insertNewByName (sSheetName & "_ttesttmp", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_ttesttmp") + oTempDataRange = fnCollectIndependentTTestData (oSheet, oLabelColumn, oScoreColumn) + + oSheets.insertNewByName (sSheetName & "_ttest", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_ttest") + + sCellXLabel = fnGetRangeName (oTempDataRange.getCellByPosition (0, 0)) + nN = oTempDataRange.getCellByPosition (0, oTempDataRange.getRows.getCount - 3).getValue + oCells = oTempDataRange.getCellRangeByPosition (0, 1, 0, nN) + sCellsXData = fnGetRangeName (oCells) + sCellYLabel = fnGetRangeName (oTempDataRange.getCellByPosition (1, 0)) + nN = oTempDataRange.getCellByPosition (1, oTempDataRange.getRows.getCount - 3).getValue + oCells = oTempDataRange.getCellRangeByPosition (1, 1, 1, nN) + sCellsYData = fnGetRangeName (oCells) + + ' Obtains the format parameters for the report. + nFormatN = fnQueryFormat (oDoc, "#,##0") + nFormatF = fnQueryFormat (oDoc, "#,###.000") + nFormatP = fnQueryFormat (oDoc, "[<0.01]#.000""**"";[<0.05]#.000""*"";#.000") + + aBorderSingle.OuterLineWidth = 2 + aBorderDouble.OuterLineWidth = 2 + aBorderDouble.InnerLineWidth = 2 + aBorderDouble.LineDistance = 2 + + ' Sets the column widths of the report. + oColumns = oSheet.getColumns + oColumns.getByIndex (0).setPropertyValue ("Width", 3060) + oColumns.getByIndex (1).setPropertyValue ("Width", 2080) + oColumns.getByIndex (2).setPropertyValue ("Width", 2080) + oColumns.getByIndex (3).setPropertyValue ("Width", 2080) + oColumns.getByIndex (4).setPropertyValue ("Width", 2080) + + nRow = -2 + + ' Group description + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Group Description") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Group") + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("N") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("X") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("s") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("sX") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + + ' The first group + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=COUNT(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellXN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=AVERAGE(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellXMean = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=STDEV(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellXS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellXS & "/SQRT(" & sCellXN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' The second group + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=COUNT(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellYN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=AVERAGE(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellYMean = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=STDEV(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellYS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellYS & "/SQRT(" & sCellYN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 2, 4, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow, 4, nRow) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' Levene's test for homogeneity of variances + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Test for Homogeneity of Variances") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Test") + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("F") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Levene’s Test") + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & fnGetLeveneTest (oTempDataRange) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellF = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (2, nRow) + sCellsN = fnGetRangeName (oTempDataRange.getCellRangeByPosition (0, oTempDataRange.getRows.getCount - 3, 1, oTempDataRange.getRows.getCount - 3)) + sCellN = fnGetRangeName (oTempDataRange.getCellByPosition (4, oTempDataRange.getRows.getCount - 3)) + sFormula = "=FDIST(" & sCellF & ";COUNT(" & sCellsN & ")-1;" & sCellN & "-COUNT(" & sCellsN & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: σ1=σ2 (homogeneity; the populations of the two groups have the same variances)." & Chr (10) & _ + "H1: σ1≠σ2 (heterogeneity; the populations of the two groups have different variances) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "σ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (nPos + 1, sNotes, "σ") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 2, 2, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, 2, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' The independent samples T-test + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Independent Samples T-Test") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Type") + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("t") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("df") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("X1-X2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' The test of the homogeneity of variances. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Homogeneity") + oCell = oSheet.getCellByPosition (1, nRow) + sSP2 = "((SUMPRODUCT(" & sCellsXData & ";" & sCellsXData & ")-POWER(SUM(" & sCellsXData & ");2)/" & sCellXN & "+SUMPRODUCT(" & sCellsYData & ";" & sCellsYData & ")-POWER(SUM(" & sCellsYData & ");2)/" & sCellYN & ")/(" & sCellXN & "+" & sCellYN & "-2))" + sFormula = "=(" & sCellXMean & "-" & sCellYMean & ")/SQRT(" & sSP2 & "*(1/" & sCellXN & "+1/" & sCellYN & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & sCellXN & "+" & sCellYN & "-2" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=TTEST(" & sCellsXData & ";" & sCellsYData & ";2;2)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellXMean & "-" & sCellYMean + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' The test of the heterogeneity of variances. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Heterogeneity") + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=(" & sCellXMean & "-" & sCellYMean & ")/SQRT(POWER(" & sCellXS & ";2)/" & sCellXN & "+POWER(" & sCellYS & ";2)/" & sCellYN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=POWER(POWER(" & sCellXS & ";2)/" & sCellXN & "+POWER(" & sCellYS & ";2)/" & sCellYN & ";2)/(POWER(" & sCellXS & ";4)/(POWER(" & sCellXN & ";2)*(" & sCellXN & "-1))+POWER(" & sCellYS & ";4)/(POWER(" & sCellYN & ";2)*(" & sCellYN & "-1)))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=TTEST(" & sCellsXData & ";" & sCellsYData & ";2;3)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellXMean & "-" & sCellYMean + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: μ1=μ2 (the populations of the two groups have the same means)." & Chr (10) & _ + "H1: μ1≠μ2 (the populations of the two groups have different means) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "μ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (nPos + 1, sNotes, "μ") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 3) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 3, 4, nRow - 3) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, 4, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) +End Sub + +' fnCollectIndependentTTestData: Collects the data for the independent T-test. +Function fnCollectIndependentTTestData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object + Dim nRow As Integer, nNRow As Integer, sCellZMean As String, sCellsN As String + Dim oCell As Object, oCells As Object, oCursor As Object + Dim sCell As String, sLabel As String, sFormula As String + Dim sCellXLabel As String, sCellsXData As String, sCellXMean As String + Dim sXLabel As String, nNX As Integer + Dim sCellsXZData As String, sCellXZMean As String + Dim sCellYLabel As String, sCellsYData As String, sCellYMean As String + Dim sYLabel As String, nNY As Integer + Dim sCellsYZData As String, sCellYZMean As String + + sCellXLabel = "" + sCellYLabel = "" + For nRow = 1 To oLabelColumn.getRows.getCount - 1 + oCell = oLabelColumn.getCellByPosition (0, nRow) + sLabel = oCell.getString + If sLabel <> "" Then + If sCellXLabel = "" Then + sCellXLabel = fnGetRangeName (oCell) + sXLabel = sLabel + Else + If sLabel <> sXLabel And sCellYLabel = "" Then + sCellYLabel = fnGetRangeName (oCell) + sYLabel = sLabel + nRow = oLabelColumn.getRows.getCount - 1 + End If + End If + End If + Next nRow + + ' The data labels + oCell = oReportSheet.getCellByPosition (0, 0) + sFormula = "=" & sCellXLabel + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (1, 0) + sFormula = "=" & sCellYLabel + oCell.setFormula (sFormula) + + ' The data + nNX = 0 + nNY = 0 + For nRow = 1 To oLabelColumn.getRows.getCount - 1 + If oLabelColumn.getCellByPosition (0, nRow).getString = sXLabel Then + nNX = nNX + 1 + sFormula = "=" & fnGetRangeName (oScoreColumn.getCellByPosition (0, nRow)) + oReportSheet.getCellByPosition (0, nNX).setFormula (sFormula) + Else + If oLabelColumn.getCellByPosition (0, nRow).getString = sYLabel Then + nNY = nNY + 1 + sFormula = "=" & fnGetRangeName (oScoreColumn.getCellByPosition (0, nRow)) + oReportSheet.getCellByPosition (1, nNY).setFormula (sFormula) + End If + End If + Next nRow + + ' Collects the data + sCellsXData = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (0, 1, 0, nNX)) + sCellsYData = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (1, 1, 1, nNY)) + If nNX > nNY Then + nNRow = nNX + 1 + Else + nNRow = nNY + 1 + End If + oCell = oReportSheet.getCellByPosition (0, nNRow) + sFormula = "=COUNT(" & sCellsXData & ")" + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (1, nNRow) + sFormula = "=COUNT(" & sCellsYData & ")" + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (0, nNRow + 1) + sFormula = "=AVERAGE(" & sCellsXData & ")" + oCell.setFormula (sFormula) + sCellXMean = fnGetLocalRangeName (oCell) + oCell = oReportSheet.getCellByPosition (1, nNRow + 1) + sFormula = "=AVERAGE(" & sCellsYData & ")" + oCell.setFormula (sFormula) + sCellYMean = fnGetLocalRangeName (oCell) + oCells = oReportSheet.getCellRangeByPosition (0, nNRow, 1, nNRow) + sCellsN = fnGetLocalRangeName (oCells) + + ' Calculates the Z values + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (0, 0)) + sFormula = "=""Z""&" & sCell + oCell = oReportSheet.getCellByPosition (2, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + For nRow = 1 To nNX + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (0, nRow)) + sFormula = "=ABS(" & sCell & "-" & sCellXMean & ")" + oCell = oReportSheet.getCellByPosition (2, nRow) + oCell.setFormula (sFormula) + Next nRow + sCellsXZData = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (2, 1, 2, nNX)) + oCell = oReportSheet.getCellByPosition (2, nNRow + 1) + sFormula = "=AVERAGE(" & sCellsXZData & ")" + oCell.setFormula (sFormula) + sCellXZMean = fnGetLocalRangeName (oCell) + + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (1, 0)) + sFormula = "=""Z""&" & sCell + oCell = oReportSheet.getCellByPosition (3, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + For nRow = 1 To nNY + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (1, nRow)) + sFormula = "=ABS(" & sCell & "-" & sCellYMean & ")" + oCell = oReportSheet.getCellByPosition (3, nRow) + oCell.setFormula (sFormula) + Next nRow + sCellsYZData = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (3, 1, 3, nNY)) + oCell = oReportSheet.getCellByPosition (3, nNRow + 1) + sFormula = "=AVERAGE(" & sCellsYZData & ")" + oCell.setFormula (sFormula) + sCellYZMean = fnGetLocalRangeName (oCell) + + ' Calculates the total average + oCell = oReportSheet.getCellByPosition (4, nNRow) + sFormula = "=SUM(" & sCellsN & ")" + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (4, nNRow + 1) + sFormula = "=AVERAGE(" & sCellsXZData & ";" & sCellsYZData & ")" + oCell.setFormula (sFormula) + sCellZMean = fnGetLocalRangeName (oCell) + + ' Calculates the difference of the Z values to their means + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (0, 0)) + sFormula = "=""dZ""&" & sCell + oCell = oReportSheet.getCellByPosition (4, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -44) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + For nRow = 1 To nNX + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (2, nRow)) + sFormula = "=" & sCell & "-" & sCellXZMean + oCell = oReportSheet.getCellByPosition (4, nRow) + oCell.setFormula (sFormula) + Next nRow + + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (1, 0)) + sFormula = "=""dZ""&" & sCell + oCell = oReportSheet.getCellByPosition (5, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -44) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + For nRow = 1 To nNY + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (3, nRow)) + sFormula = "=" & sCell & "-" & sCellYZMean + oCell = oReportSheet.getCellByPosition (5, nRow) + oCell.setFormula (sFormula) + Next nRow + + ' Calculates the difference of the Z means to the total mean + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (2, nNRow + 1)) + sFormula = "=" & sCell & "-" & sCellZMean + oCell = oReportSheet.getCellByPosition (2, nNRow + 2) + oCell.setFormula (sFormula) + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (3, nNRow + 1)) + sFormula = "=" & sCell & "-" & sCellZMean + oCell = oReportSheet.getCellByPosition (3, nNRow + 2) + oCell.setFormula (sFormula) + + fnCollectIndependentTTestData = oReportSheet.getCellRangeByPosition (0, 0, 5, nNRow + 2) +End Function + +' fnGetLeveneTest: Returns the Levene's test result. +Function fnGetLeveneTest (oZDataRange As Object) As String + Dim nK As Integer, nRows As Integer + Dim oCell As Object, oCells As Object + Dim sCellN As String, sCellsN As String + Dim sCellsDZMean As String, sCellsDZData As String + + nRows = oZDataRange.getRows.getCount + nK = oZDataRange.getColumns.getCount / 3 + oCell = oZDataRange.getCellByPosition (nK * 2, nRows - 3) + sCellN = fnGetRangeName (oCell) + oCells = oZDataRange.getCellRangeByPosition (0, nRows - 3, nK - 1, nRows - 3) + sCellsN = fnGetRangeName (oCells) + oCells = oZDataRange.getCellRangeByPosition (nK, nRows - 1, nK * 2 - 1, nRows - 1) + sCellsDZMean = fnGetRangeName (oCells) + oCells = oZDataRange.getCellRangeByPosition (nK * 2, 1, nK * 3 - 1, nRows - 4) + sCellsDZData = fnGetRangeName (oCells) + fnGetLeveneTest = "((" & sCellN & "-COUNT(" & sCellsN & "))/(COUNT(" & sCellsN & ")-1))*(SUMPRODUCT(" & sCellsN & ";" & sCellsDZMean & ";" & sCellsDZMean & ")/SUMPRODUCT(" & sCellsDZData & ";" & sCellsDZData & "))" +End Function + \ No newline at end of file diff --git a/oxt/StatTool/4ANOVA.xba b/oxt/StatTool/4ANOVA.xba new file mode 100644 index 0000000..fb3ce7c --- /dev/null +++ b/oxt/StatTool/4ANOVA.xba @@ -0,0 +1,1075 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 4ANOVA: The macros to for generating the report of ANOVA (Analyze of Variances) +' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-31 + +Option Explicit + +' subRunANOVA: Runs the ANOVA (Analyze of Variances). +Sub subRunANOVA As Object + Dim oRange As Object + Dim oSheets As Object, sSheetName As String + Dim oSheet As Object, mRanges As Object + Dim sExisted As String, nResult As Integer + + DialogLibraries.loadLibrary "StatTool" + + ' Asks the user for the data range + oRange = fnAskDataRange (ThisComponent) + If IsNull (oRange) Then + Exit Sub + End If + + ' Specifies the data + mRanges = fnSpecifyData (oRange, _ + "&10.Dlg2SpecData.txtPrompt1.Label3ITTest", _ + "&11.Dlg2SpecData.txtPrompt2.Label3ITTest") + If IsNull (mRanges) Then + Exit Sub + End If + + ' Checks the existing report + oSheets = ThisComponent.getSheets + sSheetName = oRange.getSpreadsheet.getName + sExisted = "" + If oSheets.hasByName (sSheetName & "_anova") Then + sExisted = sExisted & ", """ & sSheetName & "_anova""" + End If + If oSheets.hasByName (sSheetName & "_anovatmp") Then + sExisted = sExisted & ", """ & sSheetName & "_anovatmp""" + 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) + If nResult = IDNO Then + Exit Sub + End If + ' Drops the existing report + If oSheets.hasByName (sSheetName & "_anova") Then + oSheets.removeByname (sSheetName & "_anova") + End If + If oSheets.hasByName (sSheetName & "_anovatmp") Then + oSheets.removeByname (sSheetName & "_anovatmp") + End If + End If + + ' Reports the ANOVA (Analyze of Variances) + subReportANOVA (ThisComponent, mRanges (0), mRanges (1)) + oSheet = oSheets.getByName (sSheetName & "_anova") + + ' Makes the report sheet active. + ThisComponent.getCurrentController.setActiveSheet (oSheet) +End Sub + +' subReportANOVA: Reports the ANOVA (Analyze of Variances) +Sub subReportANOVA (oDoc As Object, oLabelColumn As Object, oScoreColumn As Object) + Dim oSheets As Object, sSheetName As String + Dim nI As Integer, nJ As Integer + Dim mNames () As String, nSheetIndex As Integer + Dim oSheet As Object, oColumns As Object, nRow As Integer, nStartRow As Integer + Dim oCell As Object, oCells As Object, oCursor As Object, oTempDataRange As Object + Dim nN As Integer, sFormula As String + Dim sNotes As String, nPos As Integer + Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer + Dim aBorderSingle As New com.sun.star.table.BorderLine + Dim aBorderDouble As New com.sun.star.table.BorderLine + + Dim nGroups As Integer + Dim mCellLabel () As String, mCellsData () As String + Dim mCellN () As String, mCellMean () As String, mCellS () As String + Dim sCellsData As String + Dim sCellF As String, sCellDFB As String, sCellDFW As String + Dim sCellsN As String, sCellN As String, sCellS As String + Dim sCellSSB As String, sCellSSW As String, sCellSST As String + Dim sCellMSB As String, sCellMSW As String + Dim sCellMeanDiff As String + + oSheets = oDoc.getSheets + sSheetName = oLabelColumn.getSpreadsheet.getName + mNames = oSheets.getElementNames + For nI = 0 To UBound (mNames) + If mNames (nI) = sSheetName Then + nSheetIndex = nI + End If + Next nI + + oSheets.insertNewByName (sSheetName & "_anovatmp", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_anovatmp") + oTempDataRange = fnCollectANOVAData (oSheet, oLabelColumn, oScoreColumn) + nGroups = oTempDataRange.getColumns.getCount / 3 + + oSheets.insertNewByName (sSheetName & "_anova", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_anova") + + ReDim mCellLabel (nGroups - 1) As String, mCellsData (nGroups - 1) As String + ReDim mCellN (nGroups - 1) As String, mCellMean (nGroups - 1) As String + ReDim mCellS (nGroups - 1) As String + + For nI = 0 To nGroups - 1 + mCellLabel (nI) = fnGetRangeName (oTempDataRange.getCellByPosition (nI, 0)) + nN = oTempDataRange.getCellByPosition (nI, oTempDataRange.getRows.getCount - 3).getValue + oCells = oTempDataRange.getCellRangeByPosition (nI, 1, nI, nN) + mCellsData (nI) = fnGetRangeName (oCells) + Next nI + + ' Obtains the format parameters for the report. + nFormatN = fnQueryFormat (oDoc, "#,##0") + nFormatF = fnQueryFormat (oDoc, "#,###.000") + nFormatP = fnQueryFormat (oDoc, "[<0.01]#.000""**"";[<0.05]#.000""*"";#.000") + + aBorderSingle.OuterLineWidth = 2 + aBorderDouble.OuterLineWidth = 2 + aBorderDouble.InnerLineWidth = 2 + aBorderDouble.LineDistance = 2 + + ' Sets the column widths of the report. + oColumns = oSheet.getColumns + oColumns.getByIndex (0).setPropertyValue ("Width", 3060) + oColumns.getByIndex (1).setPropertyValue ("Width", 3060) + oColumns.getByIndex (2).setPropertyValue ("Width", 2080) + oColumns.getByIndex (3).setPropertyValue ("Width", 2080) + oColumns.getByIndex (4).setPropertyValue ("Width", 2080) + oColumns.getByIndex (5).setPropertyValue ("Width", 2080) + oColumns.getByIndex (6).setPropertyValue ("Width", 2080) + + nRow = -2 + + ' Group description + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Group Description") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Group") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("N") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("X") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("s") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (5, nRow) + oCell.setString ("sX") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + + ' Show each group + sCellsData = "" + For nI = 0 To nGroups - 1 + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & mCellLabel (nI) + oCell.setFormula (sFormula) + mCellLabel (nI) = fnGetLocalRangeName (oCell) + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=COUNT(" & mCellsData (nI) & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + mCellN (nI) = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=AVERAGE(" & mCellsData (nI) & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + mCellMean (nI) = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=STDEV(" & mCellsData (nI) & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + mCellS (nI) = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & mCellS (nI) & "/SQRT(" & mCellN (nI) & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellsData = sCellsData & ";" & mCellsData (nI) + Next nI + sCellsData = Right (sCellsData, Len (sCellsData) - 1) + ' Shows the total + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Total") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=COUNT(" & sCellsData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellN = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=AVERAGE(" & sCellsData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=STDEV(" & sCellsData & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellS = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & sCellS & "/SQRT(" & sCellN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - nGroups - 1) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - nGroups - 1, 5, nRow - nGroups - 1) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (0, nRow - nGroups, 0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow, 5, nRow) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' Levene's test for homogeneity of variances + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Test for Homogeneity of Variances") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Test") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("F") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("dfb") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (2, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("dfw") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (2, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (5, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Levene’s Test") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & fnGetLeveneTest (oTempDataRange) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellF = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sCellsN = fnGetRangeName (oTempDataRange.getCellRangeByPosition (0, oTempDataRange.getRows.getCount - 3, nGroups - 1, oTempDataRange.getRows.getCount - 3)) + sFormula = "=COUNT(" & sCellsN & ")-1" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellDFB = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sCellN = fnGetRangeName (oTempDataRange.getCellByPosition (nGroups * 2, oTempDataRange.getRows.getCount - 3)) + sFormula = "=" & sCellN & "-COUNT(" & sCellsN & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellDFW = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=FDIST(" & sCellF & ";" & sCellDFB & ";" & sCellDFW & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: σ1=σ2=…σN (the populations of the groups have the same variances)." & Chr (10) & _ + "H1: ANOVA does not apply (the populations of the groups does not have the same variances) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "σ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (nPos + 1, sNotes, "σ") + Loop + nPos = InStr (sNotes, "σN") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 2, 5, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, 5, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' The ANOVA (analysis of variances) + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("One-way ANOVA (Analysis of Variances)") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 6, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Source of Variation") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("SS") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("df") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("MS") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (5, nRow) + oCell.setString ("F") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (6, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' Between groups + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Between Groups") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" + For nI = 0 To nGroups - 1 + sFormula = sFormula & "POWER(SUM(" & mCellsData (nI) & ");2)/" & mCellN (nI) & "+" + Next nI + sFormula = Left (sFormula, Len (sFormula) - 1) & "-POWER(SUM(" & sCellsData & ");2)/" & sCellN + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellSSB = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & sCellDFB + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellDFB = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellSSB & "/" & sCellDFB + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellMSB = fnGetLocalRangeName (oCell) + + ' Within groups + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Within Groups") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" + For nI = 0 To nGroups - 1 + sFormula = sFormula & "(SUMPRODUCT(" & mCellsData (nI) & ";" & mCellsData (nI) & ")-POWER(SUM(" & mCellsData (nI) & ");2)/" & mCellN (nI) & ")+" + Next nI + sFormula = Left (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellSSW = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & sCellDFW + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellDFW = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=" & sCellSSW & "/" & sCellDFW + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellMSW = fnGetLocalRangeName (oCell) + + nRow = nRow - 1 + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=" & sCellMSB & "/" & sCellMSW + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellF = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (6, nRow) + sFormula = "=FDIST(" & sCellF & ";" & sCellDFB & ";" & sCellDFW & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + nRow = nRow + 1 + + ' Total + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Total") + oCells = oSheet.getCellRangeByPosition (0, nRow, 1, nRow) + oCells.merge (True) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & sCellSSB & "+" & sCellSSW + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & sCellDFB & "+" & sCellDFW + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: μ1=μ2=…μN (the populations of the groups have the same means)." & Chr (10) & _ + "H1: The above is false (the populations of the groups does not have the same means) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 6, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "μ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (nPos + 1, sNotes, "μ") + Loop + nPos = InStr (sNotes, "μN") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 4) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 4, 6, nRow - 4) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (0, nRow - 3, 0, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, 6, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' The post-hoc test between groups with Scheffé's method + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Post-Hoc Test Between Groups with Scheffé's Method") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Xi") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("Xj") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("Xi-Xj") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharOverline", com.sun.star.awt.FontUnderline.SINGLE) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("F") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The tests between groups + nRow = nRow + 1 + For nI = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & mCellLabel (nI) + oCell.setFormula (sFormula) + For nJ = 0 To nGroups - 1 + If nI <> nJ Then + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & mCellLabel (nJ) + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & mCellMean (nI) & "-" & mCellMean (nJ) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellMeanDiff = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=POWER(" & sCellMeanDiff & ";2)/(" & sCellMSW & "*(1/" & mCellN (nI) & "+1/" & mCellN (nJ) & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellF = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=FDIST(" & sCellF & "/" & sCellDFB & ";" & sCellDFB & ";" & sCellDFW & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + nRow = nRow + 1 + End If + Next nJ + Next nI + nRow = nRow - 1 + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: μi=μj (the populations of the two groups have the same means)." & Chr (10) & _ + "H1: μi≠μj (the populations of the two groups have different means) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "μ") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "μ") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + nStartRow = nRow - (nGroups * (nGroups - 1)) - 1 + oCells = oSheet.getCellByPosition (0, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (1, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nStartRow, 4, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nStartRow + 1, 1, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) +End Sub + +' fnCollectANOVAData: Collects the data for the ANOVA (Analyze of Variances). +Function fnCollectANOVAData (oReportSheet As Object, oLabelColumn As Object, oScoreColumn As Object) As Object + Dim nRow As Integer, nColumn As Integer, nI As Integer + Dim nNRow As Integer, sCellZMean As String, sCellsN As String + Dim oCell As Object, oCells As Object, oCursor As Object + Dim sCell As String, sLabel As String, sFormula As String + Dim nGroups As Integer, sLabels As String + Dim mLabels () As String, mCellLabel () As String + Dim mCellsData () As String, mCellMean () As String + Dim mN () As Integer, mCellsZData () As String + Dim mCellZMean () As String + + sLabels = " " + nGroups = 0 + For nRow = 1 To oLabelColumn.getRows.getCount - 1 + sLabel = oLabelColumn.getCellByPosition (0, nRow).getString + If InStr (sLabels, " " & sLabel & " ") = 0 Then + sLabels = sLabels & sLabel & " " + nGroups = nGroups + 1 + End If + Next nRow + + ReDim mLabels (nGroups - 1) As String, mCellLabel (nGroups - 1) As String + ReDim mCellsData (nGroups - 1) As String, mCellMean (nGroups - 1) As String + ReDim mN (nGroups - 1) As Integer, mCellsZData (nGroups - 1) As String + ReDim mCellZMean (nGroups - 1) As String + + sLabels = " " + nGroups = 0 + For nRow = 1 To oLabelColumn.getRows.getCount - 1 + oCell = oLabelColumn.getCellByPosition (0, nRow) + sLabel = oCell.getString + If InStr (sLabels, " " & sLabel & " ") = 0 Then + sLabels = sLabels & sLabel & " " + mLabels (nGroups) = sLabel + mCellLabel (nGroups) = fnGetRangeName (oCell) + nGroups = nGroups + 1 + End If + Next nRow + + ' The data labels + For nI = 0 To nGroups - 1 + oCell = oReportSheet.getCellByPosition (nI, 0) + sFormula = "=" & mCellLabel (nI) + oCell.setFormula (sFormula) + Next nI + + ' The data + For nI = 0 To nGroups - 1 + mN (nI) = 0 + Next nI + For nRow = 1 To oLabelColumn.getRows.getCount - 1 + sLabel = oLabelColumn.getCellByPosition (0, nRow).getString + For nI = 0 To nGroups - 1 + If sLabel = mLabels (nI) Then + nColumn = nI + nI = nGroups - 1 + End If + Next nI + mN (nColumn) = mN (nColumn) + 1 + sFormula = "=" & fnGetRangeName (oScoreColumn.getCellByPosition (0, nRow)) + oCell = oReportSheet.getCellByPosition (nColumn, mN (nColumn)) + oCell.setFormula (sFormula) + Next nRow + + ' Collects the data + For nI = 0 To nGroups - 1 + mCellsData (nI) = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (nI, 1, nI, mN (nI))) + Next nI + nNRow = 0 + For nI = 0 To nGroups - 1 + If nNRow < mN (nI) Then + nNRow = mN (nI) + End If + Next nI + nNRow = nNRow + 1 + For nI = 0 To nGroups - 1 + oCell = oReportSheet.getCellByPosition (nI, nNRow) + sFormula = "=COUNT(" & mCellsData (nI) & ")" + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (nI, nNRow + 1) + sFormula = "=AVERAGE(" & mCellsData (nI) & ")" + oCell.setFormula (sFormula) + mCellMean (nI) = fnGetLocalRangeName (oCell) + Next nI + oCells = oReportSheet.getCellRangeByPosition (0, nNRow, nGroups - 1, nNRow) + sCellsN = fnGetLocalRangeName (oCells) + + ' Calculates the Z values + For nI = 0 To nGroups - 1 + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (nI, 0)) + sFormula = "=""Z""&" & sCell + oCell = oReportSheet.getCellByPosition (nGroups + nI, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + For nRow = 1 To mN (nI) + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (nI, nRow)) + sFormula = "=ABS(" & sCell & "-" & mCellMean (nI) & ")" + oCell = oReportSheet.getCellByPosition (nGroups + nI, nRow) + oCell.setFormula (sFormula) + Next nRow + mCellsZData (nI) = fnGetLocalRangeName (oReportSheet.getCellRangeByPosition (nGroups + nI, 1, nGroups + nI, mN (nI))) + oCell = oReportSheet.getCellByPosition (nGroups + nI, nNRow + 1) + sFormula = "=AVERAGE(" & mCellsZData (nI) & ")" + oCell.setFormula (sFormula) + mCellZMean (nI) = fnGetLocalRangeName (oCell) + Next nI + + ' Calculates the total average + oCell = oReportSheet.getCellByPosition (nGroups * 2, nNRow) + sFormula = "=SUM(" & sCellsN & ")" + oCell.setFormula (sFormula) + oCell = oReportSheet.getCellByPosition (nGroups * 2, nNRow + 1) + sFormula = "" + For nI = 0 To nGroups - 1 + sFormula = sFormula & ";" & mCellsZData (nI) + Next nI + sFormula = "=AVERAGE(" & Right (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + sCellZMean = fnGetLocalRangeName (oCell) + + ' Calculates the difference of the Z values to their means + For nI = 0 To nGroups - 1 + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (nI, 0)) + sFormula = "=""dZ""&" & sCell + oCell = oReportSheet.getCellByPosition (nGroups * 2 + nI, 0) + oCell.setFormula (sFormula) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", -44) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + For nRow = 1 To mN (nI) + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (nGroups + nI, nRow)) + sFormula = "=" & sCell & "-" & mCellZMean (nI) + oCell = oReportSheet.getCellByPosition (nGroups * 2 + nI, nRow) + oCell.setFormula (sFormula) + Next nRow + Next nI + + ' Calculates the difference of the Z means to the total mean + For nI = 0 To nGroups - 1 + sCell = fnGetLocalRangeName (oReportSheet.getCellByPosition (nGroups + nI, nNRow + 1)) + sFormula = "=" & sCell & "-" & sCellZMean + oCell = oReportSheet.getCellByPosition (nGroups + nI, nNRow + 2) + oCell.setFormula (sFormula) + Next nI + + fnCollectANOVAData = oReportSheet.getCellRangeByPosition (0, 0, nGroups * 3 - 1, nNRow + 2) +End Function + \ No newline at end of file diff --git a/oxt/StatTool/5Chi2GoF.xba b/oxt/StatTool/5Chi2GoF.xba new file mode 100644 index 0000000..4d534df --- /dev/null +++ b/oxt/StatTool/5Chi2GoF.xba @@ -0,0 +1,865 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 5Chi2GoF: The macros to for generating the report of Chi-square goodness of fit +' by imacat <imacat@mail.imacat.idv.tw>, 2016-09-05 + +Option Explicit + +' subRunChi2GoodnessOfFit: Runs the chi-square goodness of fit. +Sub subRunChi2GoodnessOfFit As Object + Dim oRange As Object + Dim oSheets As Object, sSheetName As String + Dim oSheet As Object, mRanges As Object + Dim sExisted As String, nResult As Integer + + DialogLibraries.loadLibrary "StatTool" + + ' Asks the user for the data range + oRange = fnAskDataRange (ThisComponent) + If IsNull (oRange) Then + Exit Sub + End If + + ' Specifies the data + mRanges = fnSpecifyData (oRange, _ + "&12.Dlg2SpecData.txtPrompt1.Label5Chi2GoF", _ + "&13.Dlg2SpecData.txtPrompt2.Label5Chi2GoF") + If IsNull (mRanges) Then + Exit Sub + End If + + ' Checks the existing report + oSheets = ThisComponent.getSheets + sSheetName = oRange.getSpreadsheet.getName + If oSheets.hasByName (sSheetName & "_chi2") Then + sExisted = "Spreadsheet """ & sSheetName & "_chi2"" exists. Overwrite?" + nResult = MsgBox (sExisted, MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION) + If nResult = IDNO Then + Exit Sub + End If + ' Drops the existing report + oSheets.removeByname (sSheetName & "_chi2") + End If + + ' Reports the chi-square goodness of fit + subReportChi2GoodnessOfFit (ThisComponent, mRanges (0), mRanges (1)) + oSheet = oSheets.getByName (sSheetName & "_chi2") + + ' Makes the report sheet active. + ThisComponent.getCurrentController.setActiveSheet (oSheet) +End Sub + +' subReportChi2GoodnessOfFit: Reports the chi-square goodness of fit +Sub subReportChi2GoodnessOfFit (oDoc As Object, oColumnColumn As Object, oRowColumn As Object) + Dim oSheets As Object, sSheetName As String + Dim nI As Integer, nJ As Integer, nJ1 As Integer, nJ2 As Integer + Dim mNames () As String, nSheetIndex As Integer + Dim oSheet As Object, oColumns As Object, nRow As Integer, nStartRow As Integer + Dim oCell As Object, oCells As Object, oCursor As Object + Dim nN As Integer, sFormula As String + Dim sNotes As String, nPos As Integer + Dim nFormatN As Integer, nFormatF As Integer, nFormatP As Integer, nFormatPct As Integer + Dim aBorderSingle As New com.sun.star.table.BorderLine + Dim aBorderDouble As New com.sun.star.table.BorderLine + + Dim sCellsJData As String, sCellsIData As String + Dim sLabel As String, sLabelsColumn As String, sLabelsRow As String + Dim nGroups As Integer, nEvents As Integer + Dim mCellLabelColomn () As String, mCellLabelRow () As String + Dim mCellNJ () As String, mCellNI () As String, mCellPI () As String + Dim mCellFrequency (0, 0) As String, mCellProportion (0, 0) As String + Dim sCellN As String + + Dim sCell As String, sCells As String + Dim sCellsRow As String, sCellsColumn As String + Dim sCellChi2 As String, sCellDF As String + Dim sSE2 AS String, nTotalColumns As Integer + + oSheets = oDoc.getSheets + sSheetName = oColumnColumn.getSpreadsheet.getName + mNames = oSheets.getElementNames + For nI = 0 To UBound (mNames) + If mNames (nI) = sSheetName Then + nSheetIndex = nI + End If + Next nI + oSheets.insertNewByName (sSheetName & "_chi2", nSheetIndex + 1) + oSheet = oSheets.getByName (sSheetName & "_chi2") + + sCellsJData = fnGetRangeName (oColumnColumn.getCellRangeByPosition (0, 1, 0, oColumnColumn.getRows.getCount - 1)) + sCellsIData = fnGetRangeName (oRowColumn.getCellRangeByPosition (0, 1, 0, oRowColumn.getRows.getCount - 1)) + + ' Counts the number of groups and events + sLabelsColumn = " " + sLabelsRow = " " + nGroups = 0 + nEvents = 0 + For nRow = 1 To oColumnColumn.getRows.getCount - 1 + sLabel = oColumnColumn.getCellByPosition (0, nRow).getString + If InStr (sLabelsColumn, " " & sLabel & " ") = 0 Then + sLabelsColumn = sLabelsColumn & sLabel & " " + nGroups = nGroups + 1 + End If + sLabel = oRowColumn.getCellByPosition (0, nRow).getString + If InStr (sLabelsRow, " " & sLabel & " ") = 0 Then + sLabelsRow = sLabelsRow & sLabel & " " + nEvents = nEvents + 1 + End If + Next nRow + + ReDim mCellLabelColomn (nGroups - 1) As String, mCellLabelRow (nEvents - 1) As String + ReDim mCellNJ (nGroups - 1) As String, mCellNI (nEvents - 1) As String + ReDim mCellPI (nEvents - 1) As String + ReDim mCellFrequency (nGroups - 1, nEvents - 1) As String + ReDim mCellProportion (nGroups - 1, nEvents - 1) As String + + ' Collects the group and event labels + sLabelsColumn = " " + sLabelsRow = " " + nJ = 0 + nI = 0 + For nRow = 1 To oColumnColumn.getRows.getCount - 1 + oCell = oColumnColumn.getCellByPosition (0, nRow) + sLabel = oCell.getString + If InStr (sLabelsColumn, " " & sLabel & " ") = 0 Then + sLabelsColumn = sLabelsColumn & sLabel & " " + mCellLabelColomn (nJ) = fnGetRangeName (oCell) + nJ = nJ + 1 + End If + oCell = oRowColumn.getCellByPosition (0, nRow) + sLabel = oCell.getString + If InStr (sLabelsRow, " " & sLabel & " ") = 0 Then + sLabelsRow = sLabelsRow & sLabel & " " + mCellLabelRow (nI) = fnGetRangeName (oCell) + nI = nI + 1 + End If + Next nRow + + ' Obtains the format parameters for the report. + nFormatN = fnQueryFormat (oDoc, "#,##0") + nFormatF = fnQueryFormat (oDoc, "#,###.000") + nFormatP = fnQueryFormat (oDoc, "[<0.01]#.000""**"";[<0.05]#.000""*"";#.000") + nFormatPct = fnQueryFormat (oDoc, "0.0%") + + aBorderSingle.OuterLineWidth = 2 + aBorderDouble.OuterLineWidth = 2 + aBorderDouble.InnerLineWidth = 2 + aBorderDouble.LineDistance = 2 + + ' Sets the column widths of the report. + nTotalColumns = nGroups + 2 + If nEvents = 2 Then + If nTotalColumns < 5 Then + nTotalColumns = 5 + End If + Else + If nTotalColumns < 6 Then + nTotalColumns = 6 + End If + End If + oColumns = oSheet.getColumns + For nJ = 0 To nTotalColumns - 1 + oColumns.getByIndex (nJ).setPropertyValue ("Width", 3060) + Next nJ + + nRow = -2 + + ' Group description + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Crosstabulation") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, nGroups + 1, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Event") + For nJ = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (nJ + 1, nRow) + sFormula = "=" & mCellLabelColomn (nJ) + oCell.setFormula (sFormula) + mCellLabelColomn (nJ) = fnGetLocalRangeName (oCell) + Next nJ + oCell = oSheet.getCellByPosition (nGroups + 1, nRow) + oCell.setString ("Total") + + ' Shows each event + nRow = nRow - 1 + For nI = 0 To nEvents - 1 + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & mCellLabelRow (nI) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("VertJustify", com.sun.star.table.CellVertJustify.TOP) + mCellLabelRow (nI) = fnGetLocalRangeName (oCell) + oCells = oSheet.getCellRangeByPosition (0, nRow, 0, nRow + 1) + oCells.merge (True) + For nJ = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (1 + nJ, nRow) + sFormula = "=COUNTIFS(" & sCellsJData & ";" & mCellLabelColomn (nJ) & ";" & sCellsIData & ";" & mCellLabelRow (nI) & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + mCellFrequency (nJ, nI) = fnGetLocalRangeName (oCell) + Next nJ + oCell = oSheet.getCellByPosition (1 + nGroups, nRow) + sCells = fnGetLocalRangeName (oSheet.getCellRangeByPosition (1, nRow, nGroups, nRow)) + sFormula = "=SUM(" & sCells & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + mCellNI (nI) = fnGetLocalRangeName (oCell) + Next nI + ' Shows the total + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Total") + oCell.setPropertyValue ("VertJustify", com.sun.star.table.CellVertJustify.TOP) + oCells = oSheet.getCellRangeByPosition (0, nRow, 0, nRow + 1) + oCells.merge (True) + For nJ = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (1 + nJ, nRow) + sFormula = "" + For nI = 0 To nEvents - 1 + sFormula = sFormula & "+" & mCellFrequency (nJ, nI) + Next nI + sFormula = "=" & Right (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + mCellNJ (nJ) = fnGetLocalRangeName (oCell) + Next nJ + oCell = oSheet.getCellByPosition (1 + nGroups, nRow) + sCells = fnGetLocalRangeName (oSheet.getCellRangeByPosition (1, nRow, nGroups, nRow)) + sFormula = "" + For nI = 0 To nEvents - 1 + sFormula = sFormula & "+" & mCellNI (nI) + Next nI + sFormula = "=" & Right (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellN = fnGetLocalRangeName (oCell) + ' Shows the proportions + nRow = nRow - nEvents * 2 - 1 + For nI = 0 To nEvents - 1 + nRow = nRow + 2 + For nJ = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (1 + nJ, nRow) + sFormula = "=" & mCellFrequency (nJ, nI) & "/" & mCellNJ (nJ) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + mCellProportion (nJ, nI) = fnGetLocalRangeName (oCell) + Next nJ + oCell = oSheet.getCellByPosition (1 + nGroups, nRow) + sFormula = "=" & mCellNI (nI) & "/" & sCellN + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + mCellPI (nI) = fnGetLocalRangeName (oCell) + Next nI + ' Shows the total + nRow = nRow + 2 + For nJ = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (1 + nJ, nRow) + sFormula = "" + For nI = 0 To nEvents - 1 + sFormula = sFormula & "+" & mCellProportion (nJ, nI) + Next nI + sFormula = "=" & Right (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + Next nJ + oCell = oSheet.getCellByPosition (1 + nGroups, nRow) + sCells = fnGetLocalRangeName (oSheet.getCellRangeByPosition (1, nRow, nGroups, nRow)) + sFormula = "" + For nI = 0 To nEvents - 1 + sFormula = sFormula & "+" & mCellPI (nI) + Next nI + sFormula = "=" & Right (sFormula, Len (sFormula) - 1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + + oCells = oSheet.getCellRangeByPosition (1, nRow - nEvents * 2 - 1, nGroups, nRow - nEvents * 2 - 1) + sCellsRow = fnGetLocalRangeName (oCells) + oCells = oSheet.getCellRangeByPosition (1, nRow - nEvents * 2 - 1, 1, nRow - 2) + sCellsColumn = fnGetLocalRangeName (oCells) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - nEvents * 2 - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - nEvents * 2 - 2, nGroups + 1, nRow - nEvents * 2 - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (0, nRow - nEvents * 2 - 1, 0, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, nGroups + 1, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow, nGroups + 1, nRow) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' The Chi-square test + nRow = nRow + 2 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Chi-Square Test") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 3, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Test") + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("χ2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", 33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("df") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + + ' The test result. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Pearson’s Chi-Square") + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "" + For nI = 0 To nEvents - 1 + For nJ = 0 To nGroups - 1 + sFormula = sFormula & "+POWER(" & mCellFrequency (nJ, nI) & ";2)/(" & mCellNI (nI) & "*" & mCellNJ (nJ) & ")" + Next nJ + Next nI + sFormula = "=" & sCellN & "*(" & Right (sFormula, Len (sFormula) - 1) & "-1)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + sCellChi2 = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=(COUNT(" & sCellsRow & ")-1)*(COUNT(" & sCellsColumn & ")/2-1)" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatN) + sCellDF = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=CHIDIST(" & sCellChi2 & ";" & sCellDF & ")" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: P1=P2=…PN=P (the proportions of the events in each group are the same)." & Chr (10) & _ + "H1: The above is false (the proportions of the events in each group are different) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + oCells = oSheet.getCellRangeByPosition (0, nRow, 3, nRow) + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (1, sNotes, "P", 0) + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + If oCursor.getString <> " " Then + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + End If + nPos = InStr (nPos + 1, sNotes, "P", 0) + Loop + nPos = InStr (sNotes, "PN") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + oCells = oSheet.getCellByPosition (0, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nRow - 2, 3, nRow - 2) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (1, nRow - 1, 3, nRow - 1) + oCells.setPropertyValue ("TopBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + + ' The posteriori comparison + nRow = nRow + 2 + If nEvents = 2 Then + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Posteriori Comparison") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("j1") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("j2") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("Pj1-Pj2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -52) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + oCursor.collapseToEnd + oCursor.goRight (1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -52) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("χ2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", 33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + Else + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Posteriori Comparison") + oCell.setPropertyValue ("CellStyle", "Result2") + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + oCells.merge (True) + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Event") + oCell = oSheet.getCellByPosition (1, nRow) + oCell.setString ("j1") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (2, nRow) + oCell.setString ("j2") + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (3, nRow) + oCell.setString ("Pj1-Pj2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -52) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + oCursor.collapseToEnd + oCursor.goRight (1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -52) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + oCell = oSheet.getCellByPosition (4, nRow) + oCell.setString ("χ2") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharEscapement", 33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCell = oSheet.getCellByPosition (5, nRow) + oCell.setString ("p") + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + oCursor = oCell.createTextCursor + oCursor.gotoStart (False) + oCursor.gotoEnd (True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + End If + + ' The comparison between groups + nRow = nRow + 1 + If nEvents = 2 Then + For nJ1 = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & mCellLabelColomn (nJ1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("VertJustify", com.sun.star.table.CellVertJustify.TOP) + oCells = oSheet.getCellRangeByPosition (0, nRow, 0, nRow + (nGroups - 1) - 1) + oCells.merge (True) + For nJ2 = 0 To nGroups - 1 + If nJ1 <> nJ2 Then + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & mCellLabelColomn (nJ2) + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & mCellProportion (nJ1, 0) & "-" & mCellProportion (nJ2, 0) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + sCell = fnGetLocalRangeName (oCell) + sSE2 = "(" & mCellProportion (nJ1, 0) & "*(1-" & mCellProportion (nJ1, 0) & "))/" & mCellNJ (nJ1) & _ + "+(" & mCellProportion (nJ2, 0) & "*(1-" & mCellProportion (nJ2, 0) & "))/" & mCellNJ (nJ2) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=IF(" & sSE2 & "=0;""(N/A)"";POWER(" & sCell & ";2)/(" & sSE2 & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + sCellChi2 = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=IF(" & sSE2 & "=0;""(N/A)"";CHIDIST(" & sCellChi2 & ";" & sCellDF & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + nRow = nRow + 1 + End If + Next nJ2 + Next nJ1 + Else + For nI = 0 To nEvents - 1 + oCell = oSheet.getCellByPosition (0, nRow) + sFormula = "=" & mCellLabelRow (nI) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("VertJustify", com.sun.star.table.CellVertJustify.TOP) + oCells = oSheet.getCellRangeByPosition (0, nRow, 0, nRow + nGroups * (nGroups - 1) - 1) + oCells.merge (True) + For nJ1 = 0 To nGroups - 1 + oCell = oSheet.getCellByPosition (1, nRow) + sFormula = "=" & mCellLabelColomn (nJ1) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("VertJustify", com.sun.star.table.CellVertJustify.TOP) + oCells = oSheet.getCellRangeByPosition (1, nRow, 1, nRow + (nGroups - 1) - 1) + oCells.merge (True) + For nJ2 = 0 To nGroups - 1 + If nJ1 <> nJ2 Then + oCell = oSheet.getCellByPosition (2, nRow) + sFormula = "=" & mCellLabelColomn (nJ2) + oCell.setFormula (sFormula) + oCell = oSheet.getCellByPosition (3, nRow) + sFormula = "=" & mCellProportion (nJ1, nI) & "-" & mCellProportion (nJ2, nI) + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatPct) + sCell = fnGetLocalRangeName (oCell) + sSE2 = "(" & mCellProportion (nJ1, nI) & "*(1-" & mCellProportion (nJ1, nI) & "))/" & mCellNJ (nJ1) & _ + "+(" & mCellProportion (nJ2, nI) & "*(1-" & mCellProportion (nJ2, nI) & "))/" & mCellNJ (nJ2) + oCell = oSheet.getCellByPosition (4, nRow) + sFormula = "=IF(" & sSE2 & "=0;""(N/A)"";POWER(" & sCell & ";2)/(" & sSE2 & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatF) + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + sCellChi2 = fnGetLocalRangeName (oCell) + oCell = oSheet.getCellByPosition (5, nRow) + sFormula = "=IF(" & sSE2 & "=0;""(N/A)"";CHIDIST(" & sCellChi2 & ";" & sCellDF & "))" + oCell.setFormula (sFormula) + oCell.setPropertyValue ("NumberFormat", nFormatP) + oCell.setPropertyValue ("ParaAdjust", com.sun.star.style.ParagraphAdjust.RIGHT) + nRow = nRow + 1 + End If + Next nJ2 + Next nJ1 + Next nI + End If + nRow = nRow - 1 + + ' The foot notes of the test. + nRow = nRow + 1 + oCell = oSheet.getCellByPosition (0, nRow) + oCell.setString ("Note: *: p<.05, **: p<.01" & Chr (10) & _ + "H0: Pj1=Pj2 (the proportions of the event in the two groups are the same)." & Chr (10) & _ + "H1: Pj1≠Pj2 (the proportions of the event in the two groups are different) if the probability (p) is small enough.") + oCell.setPropertyValue ("IsTextWrapped", True) + If nEvents = 2 Then + oCells = oSheet.getCellRangeByPosition (0, nRow, 4, nRow) + Else + oCells = oSheet.getCellRangeByPosition (0, nRow, 5, nRow) + End If + oCells.merge (True) + sNotes = oCell.getString + oCursor = oCell.createTextCursor + nPos = InStr (sNotes, "p<") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (nPos + 1, sNotes, "p<") + Loop + nPos = InStr (sNotes, "(p)") + oCursor.gotoStart (False) + oCursor.goRight (nPos, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + nPos = InStr (sNotes, "Pj") + Do While nPos <> 0 + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -52) + oCursor.setPropertyValue ("CharEscapementHeight", 34) + nPos = InStr (nPos + 1, sNotes, "Pj") + Loop + nPos = InStr (sNotes, "H0") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + nPos = InStr (sNotes, "H1") + oCursor.gotoStart (False) + oCursor.goRight (nPos - 1, False) + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharPosture", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureAsian", com.sun.star.awt.FontSlant.ITALIC) + oCursor.setPropertyValue ("CharPostureComplex", com.sun.star.awt.FontSlant.ITALIC) + oCursor.collapseToEnd + oCursor.goRight (1, True) + oCursor.setPropertyValue ("CharEscapement", -33) + oCursor.setPropertyValue ("CharEscapementHeight", 58) + + ' Draws the table borders. + If nEvents = 2 Then + nStartRow = nRow - nGroups * (nGroups - 1) - 1 + oCells = oSheet.getCellByPosition (0, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (1, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nStartRow, 4, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (1, nStartRow + 1, 1, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1 - (nGroups - 1) + 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (2, nRow - 1, 4, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + Else + nStartRow = nRow - nEvents * nGroups * (nGroups - 1) - 1 + oCells = oSheet.getCellRangeByPosition (0, nStartRow, 1, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (2, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (3, nStartRow, 5, nStartRow) + oCells.setPropertyValue ("TopBorder", aBorderDouble) + oCells.setPropertyValue ("BottomBorder", aBorderSingle) + oCells = oSheet.getCellRangeByPosition (2, nStartRow + 1, 2, nRow - 2) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells = oSheet.getCellByPosition (0, nRow - 1 - nGroups * (nGroups - 1) + 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (1, nRow - 1 - (nGroups - 1) + 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellByPosition (2, nRow - 1) + oCells.setPropertyValue ("RightBorder", aBorderSingle) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + oCells = oSheet.getCellRangeByPosition (3, nRow - 1, 5, nRow - 1) + oCells.setPropertyValue ("BottomBorder", aBorderDouble) + End If +End Sub + \ No newline at end of file diff --git a/oxt/StatTool/9Utils.xba b/oxt/StatTool/9Utils.xba new file mode 100644 index 0000000..9280a73 --- /dev/null +++ b/oxt/StatTool/9Utils.xba @@ -0,0 +1,225 @@ + + +' Copyright (c) 2016 imacat. +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. + +' 9Utils: The utility macros. +' by imacat <imacat@mail.imacat.idv.tw>, 2016-08-10 + +Option Explicit + +' fnCheckRangeName: Checks the range name and returns the range when +' found, or null when not found. +Function fnCheckRangeName (oDoc As Object, sRangeName As String) As Object + On Error Goto ErrorHandler + Dim oController As Object, oSheet As Object + Dim nPos As Integer, sSheetName As String, oRange As Object + + oController = oDoc.getCurrentController + nPos = InStr (sRangeName, ".") + If nPos = 0 Then + oSheet = oController.getActiveSheet + Else + sSheetName = Left (sRangeName, nPos - 1) + If Left (sSheetName, 1) = "$" Then + sSheetName = Right (sSheetName, Len (sSheetName) - 1) + End If + oSheet = oDoc.getSheets.getByName (sSheetName) + End If + fnCheckRangeName = oSheet.getCellRangeByName (sRangeName) + + ErrorHandler: +End Function + +' fnQueryFormat: Returns the index of the number format, and creates +' the number format if required. +Function fnQueryFormat (oDoc As Object, sFormat As String) As Integer + Dim oFormats As Object, nIndex As Integer + Dim aLocale As New com.sun.star.lang.Locale + + oFormats = oDoc.getNumberFormats + nIndex = oFormats.queryKey (sFormat, aLocale, True) + If nIndex = -1 Then + oFormats.addNew (sFormat, aLocale) + nIndex = oFormats.queryKey (sFormat, aLocale, True) + End If + fnQueryFormat = nIndex +End Function + +' fnGetRangeName: Obtains the name of a spreadsheet cell range +Function fnGetRangeName (oRange As Object) As String + Dim nPos As Integer, sName As String + + sName = oRange.getPropertyValue ("AbsoluteName") + nPos = InStr (sName, "$") + Do While nPos <> 0 + sName = Left (sName, nPos - 1) & Right (sName, Len (sName) - nPos) + nPos = InStr (sName, "$") + Loop + fnGetRangeName = sName +End Function + +' fnGetLocalRangeName: Obtains the name of a local spreadsheet cell range +Function fnGetLocalRangeName (oRange As Object) As String + Dim nPos As Integer, sName As String + + sName = fnGetRangeName (oRange) + nPos = InStr (sName, ".") + If nPos <> 0 Then + sName = Right (sName, Len (sName) - nPos) + End If + fnGetLocalRangeName = sName +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.StatTool.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 +' the user cancelled +Function fnAskDataRange (oDoc As Object) As Object + Dim oRange As Object + Dim oDialog As Object, nResult As Integer + Dim oTextModel As Object, oEditModel As Object + Dim sPrompt As String, sCellsData As String + + oRange = fnFindActiveDataRange (oDoc) + If IsNull (oRange) Then + sCellsData = "" + Else + sCellsData = oRange.getPropertyValue ("AbsoluteName") + End If + sPrompt = "&27.Dlg1AskRange.txtPrompt.Label" + + ' Loop until we finds good data + Do While sPrompt <> "" + ' Runs the dialog + oDialog = CreateUnoDialog (DialogLibraries.StatTool.Dlg1AskRange) + oTextModel = oDialog.getControl ("txtPrompt").getModel + oTextModel.setPropertyValue ("Label", sPrompt) + oEditModel = oDialog.getControl ("edtCellsData").getModel + oEditModel.setPropertyValue ("Text", sCellsData) + + nResult = oDialog.execute + oDialog.dispose + + ' Cancelled + If nResult = 0 Then + Exit Function + End If + + sCellsData = oEditModel.getPropertyValue ("Text") + If sCellsData = "" Then + sPrompt = "&27.Dlg1AskRange.txtPrompt.Label" + Else + oRange = fnCheckRangeName (oDoc, sCellsData) + If IsNull (oRange) Then + sPrompt = "&35.Dlg1AskRange.txtPrompt.LabelNotExists" + Else + If oRange.getRows.getCount < 2 Or oRange.getColumns.getCount < 2 Then + sPrompt = "&36.Dlg1AskRange.txtPrompt.LabelTooSmall" + Else + sPrompt = "" + oDoc.getCurrentController.select (oRange) + fnAskDataRange = oRange + Exit Function + End If + End If + End If + Loop +End Function + +' fnFindActiveDataRange: Finds the selected data range. +Function fnFindActiveDataRange (oDoc) + Dim oSelection As Object, nI As Integer + Dim oRanges As Object, oRange As Object + Dim aCellAddress As New com.sun.star.table.CellAddress + Dim aRangeAddress As New com.sun.star.table.CellRangeAddress + + oSelection = oDoc.getCurrentSelection + + ' Some data ranges are already selected. + If Not oSelection.supportsService ("com.sun.star.sheet.SheetCell") Then + ' Takes the first selection in multiple selections + If oSelection.supportsService ("com.sun.star.sheet.SheetCellRanges") Then + fnFindActiveDataRange = oSelection.getByIndex (0) + ' The only selection + Else + fnFindActiveDataRange = oSelection + End If + Exit Function + End If + + ' Finds the data range containing the single active cell + aCellAddress = oSelection.getCellAddress + oRanges = oSelection.getSpreadsheet.queryContentCells ( _ + com.sun.star.sheet.CellFlags.VALUE _ + + com.sun.star.sheet.CellFlags.DATETIME _ + + com.sun.star.sheet.CellFlags.STRING _ + + com.sun.star.sheet.CellFlags.FORMULA) + For nI = 0 To oRanges.getCount - 1 + oRange = oRanges.getByIndex (nI) + aRangeAddress = oRange.getRangeAddress + If aRangeAddress.StartRow <= aCellAddress.Row _ + And aRangeAddress.EndRow >= aCellAddress.Row _ + And aRangeAddress.StartColumn <= aCellAddress.Column _ + And aRangeAddress.EndColumn >= aCellAddress.Column Then + oDoc.getCurrentController.select (oRange) + fnFindActiveDataRange = oRange + Exit Function + End If + Next nI + ' Not in a data cell range +End Function + \ No newline at end of file diff --git a/oxt/StatTool/DialogStrings_en_US.default b/oxt/StatTool/DialogStrings_en_US.default new file mode 100644 index 0000000..e69de29 diff --git a/oxt/StatTool/DialogStrings_en_US.properties b/oxt/StatTool/DialogStrings_en_US.properties new file mode 100644 index 0000000..76e8b0a --- /dev/null +++ b/oxt/StatTool/DialogStrings_en_US.properties @@ -0,0 +1,24 @@ +# Strings for Dialog Library StatTool +0.Dlg2SpecData.HelpText= +1.Dlg2SpecData.Title=Step 2/2: Specify the data +2.Dlg2SpecData.txtPrompt1.HelpText= +3.Dlg2SpecData.txtPrompt1.Label1CorRel=First scores: +4.Dlg2SpecData.lstData1.HelpText= +5.Dlg2SpecData.txtPrompt2.HelpText= +6.Dlg2SpecData.txtPrompt2.Label1CorRel=Second scores: +7.Dlg2SpecData.lstData2.HelpText= +8.Dlg2SpecData.btnCancel.HelpText= +9.Dlg2SpecData.btnOK.HelpText= +10.Dlg2SpecData.txtPrompt1.Label3ITTest=Groups: +11.Dlg2SpecData.txtPrompt2.Label3ITTest=Scores: +12.Dlg2SpecData.txtPrompt1.Label5Chi2GoF=Groups (column): +13.Dlg2SpecData.txtPrompt2.Label5Chi2GoF=Events (row): +16.Dlg1AskRange.HelpText= +17.Dlg1AskRange.Title=Step 1/2: Select the data range +26.Dlg1AskRange.txtPrompt.HelpText= +27.Dlg1AskRange.txtPrompt.Label="Cells with the data:" +30.Dlg1AskRange.edtCellsData.HelpText= +32.Dlg1AskRange.btnCancel.HelpText= +34.Dlg1AskRange.btnOK.HelpText= +35.Dlg1AskRange.txtPrompt.LabelNotExists=This range does not exist. +36.Dlg1AskRange.txtPrompt.LabelTooSmall=This range is too small. (at least 2\u00d72) diff --git a/oxt/StatTool/DialogStrings_zh_CN.properties b/oxt/StatTool/DialogStrings_zh_CN.properties new file mode 100644 index 0000000..035af89 --- /dev/null +++ b/oxt/StatTool/DialogStrings_zh_CN.properties @@ -0,0 +1,24 @@ +# Strings for Dialog Library StatTool +0.Dlg2SpecData.HelpText= +1.Dlg2SpecData.Title=\u6b65\u9aa4 2/2 \uff1a\u6570\u636e\u6e90\u8bbe\u5b9a +2.Dlg2SpecData.txtPrompt1.HelpText= +3.Dlg2SpecData.txtPrompt1.Label1CorRel=\u7b2c\u4e00\u7ec4\uff1a +4.Dlg2SpecData.lstData1.HelpText= +5.Dlg2SpecData.txtPrompt2.HelpText= +6.Dlg2SpecData.txtPrompt2.Label1CorRel=\u7b2c\u4e8c\u7ec4\uff1a +7.Dlg2SpecData.lstData2.HelpText= +8.Dlg2SpecData.btnCancel.HelpText= +9.Dlg2SpecData.btnOK.HelpText= +10.Dlg2SpecData.txtPrompt1.Label3ITTest=\u5206\u7ec4\uff1a +11.Dlg2SpecData.txtPrompt2.Label3ITTest=\u5206\u6570\uff1a +12.Dlg2SpecData.txtPrompt1.Label5Chi2GoF=\u5206\u7d44\uff08\u76f4\u6b04\uff09\uff1a +13.Dlg2SpecData.txtPrompt2.Label5Chi2GoF=\u4e8b\u4ef6\uff08\u6a6b\u5217\uff09\uff1a +16.Dlg1AskRange.HelpText= +17.Dlg1AskRange.Title=\u6b65\u9aa4 1/2 \uff1a\u8bbe\u5b9a\u6570\u636e\u8303\u56f4 +26.Dlg1AskRange.txtPrompt.HelpText= +27.Dlg1AskRange.txtPrompt.Label=\u6570\u636e\u8303\u56f4\uff1a +30.Dlg1AskRange.edtCellsData.HelpText= +32.Dlg1AskRange.btnCancel.HelpText= +34.Dlg1AskRange.btnOK.HelpText= +35.Dlg1AskRange.txtPrompt.LabelNotExists=\u67e5\u65e0\u6b64\u6570\u636e\u8303\u56f4\u3002 +36.Dlg1AskRange.txtPrompt.LabelTooSmall=\u6570\u636e\u8303\u56f4\u592a\u5c0f\uff08\u81f3\u5c11\u5e94\u6709 2\u00d72 \uff09\u3002 diff --git a/oxt/StatTool/DialogStrings_zh_TW.properties b/oxt/StatTool/DialogStrings_zh_TW.properties new file mode 100644 index 0000000..05033d9 --- /dev/null +++ b/oxt/StatTool/DialogStrings_zh_TW.properties @@ -0,0 +1,24 @@ +# Strings for Dialog Library StatTool +0.Dlg2SpecData.HelpText= +1.Dlg2SpecData.Title=\u6b65\u9a5f 2/2 \uff1a\u8a2d\u5b9a\u8cc7\u6599\u4f86\u6e90 +2.Dlg2SpecData.txtPrompt1.HelpText= +3.Dlg2SpecData.txtPrompt1.Label1CorRel=\u7b2c\u4e00\u7d44\uff1a +4.Dlg2SpecData.lstData1.HelpText= +5.Dlg2SpecData.txtPrompt2.HelpText= +6.Dlg2SpecData.txtPrompt2.Label1CorRel=\u7b2c\u4e8c\u7d44\uff1a +7.Dlg2SpecData.lstData2.HelpText= +8.Dlg2SpecData.btnCancel.HelpText= +9.Dlg2SpecData.btnOK.HelpText= +10.Dlg2SpecData.txtPrompt1.Label3ITTest=\u5206\u7d44\uff1a +11.Dlg2SpecData.txtPrompt2.Label3ITTest=\u5206\u6578\uff1a +12.Dlg2SpecData.txtPrompt1.Label5Chi2GoF=\u5206\u7d44\uff08\u76f4\u6b04\uff09\uff1a +13.Dlg2SpecData.txtPrompt2.Label5Chi2GoF=\u4e8b\u4ef6\uff08\u6a6b\u5217\uff09\uff1a +16.Dlg1AskRange.HelpText= +17.Dlg1AskRange.Title=\u6b65\u9a5f 1/2 \uff1a\u8a2d\u5b9a\u8cc7\u6599\u7bc4\u570d +26.Dlg1AskRange.txtPrompt.HelpText= +27.Dlg1AskRange.txtPrompt.Label=\u8cc7\u6599\u7bc4\u570d\uff1a +30.Dlg1AskRange.edtCellsData.HelpText= +32.Dlg1AskRange.btnCancel.HelpText= +34.Dlg1AskRange.btnOK.HelpText= +35.Dlg1AskRange.txtPrompt.LabelNotExists=\u67e5\u7121\u6b64\u8cc7\u6599\u7bc4\u570d\u3002 +36.Dlg1AskRange.txtPrompt.LabelTooSmall=\u8cc7\u6599\u7bc4\u570d\u592a\u5c0f\uff08\u81f3\u5c11\u61c9\u6709 2\u00d72 \uff09\u3002 diff --git a/oxt/StatTool/Dlg1AskRange.xdl b/oxt/StatTool/Dlg1AskRange.xdl new file mode 100644 index 0000000..7f6509d --- /dev/null +++ b/oxt/StatTool/Dlg1AskRange.xdl @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/oxt/StatTool/Dlg2SpecData.xdl b/oxt/StatTool/Dlg2SpecData.xdl new file mode 100644 index 0000000..a3d21d3 --- /dev/null +++ b/oxt/StatTool/Dlg2SpecData.xdl @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/oxt/StatTool/dialog.xlb b/oxt/StatTool/dialog.xlb new file mode 100644 index 0000000..529bd92 --- /dev/null +++ b/oxt/StatTool/dialog.xlb @@ -0,0 +1,6 @@ + + + + + + diff --git a/oxt/StatTool/script.xlb b/oxt/StatTool/script.xlb new file mode 100644 index 0000000..2599f14 --- /dev/null +++ b/oxt/StatTool/script.xlb @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/oxt/description.xml b/oxt/description.xml new file mode 100644 index 0000000..ebe3686 --- /dev/null +++ b/oxt/description.xml @@ -0,0 +1,26 @@ + + + + + + + imacat + 依瑪貓 + 依玛猫 + + + + + + + + Office Statistics Tools + Office 統計工具 + Office 统计工具 + + diff --git a/oxt/pkg-desc/pkg-description.txt b/oxt/pkg-desc/pkg-description.txt new file mode 100644 index 0000000..aaa94a5 --- /dev/null +++ b/oxt/pkg-desc/pkg-description.txt @@ -0,0 +1,4 @@ +StatTool - Office Statistics Tools +Copyright (c) 2016 imacat + +An additional Calc menu to for statistical tests. diff --git a/oxt/pkg-desc/pkg-description.zh-CN.txt b/oxt/pkg-desc/pkg-description.zh-CN.txt new file mode 100644 index 0000000..e184170 --- /dev/null +++ b/oxt/pkg-desc/pkg-description.zh-CN.txt @@ -0,0 +1,4 @@ +StatTool - Office 统计工具 +版权所有 (c) 2016 依玛猫 + +新增 Calc 试算表统计菜单,计算统计检定。 diff --git a/oxt/pkg-desc/pkg-description.zh-TW.txt b/oxt/pkg-desc/pkg-description.zh-TW.txt new file mode 100644 index 0000000..8708448 --- /dev/null +++ b/oxt/pkg-desc/pkg-description.zh-TW.txt @@ -0,0 +1,4 @@ +StatTool - Office 統計工具 +版權所有 (c) 2016 依瑪貓 + +新增 Calc 試算表統計選單,計算統計檢定。 diff --git a/oxt/registration/LICENSE b/oxt/registration/LICENSE new file mode 100644 index 0000000..3007bca --- /dev/null +++ b/oxt/registration/LICENSE @@ -0,0 +1,611 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +APACHE HTTP SERVER SUBCOMPONENTS: + +The Apache HTTP Server includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +For the mod_mime_magic component: + +/* + * mod_mime_magic: MIME type lookup via file magic numbers + * Copyright (c) 1996-1997 Cisco Systems, Inc. + * + * This software was submitted by Cisco Systems to the Apache Group in July + * 1997. Future revisions and derivatives of this source code must + * acknowledge Cisco Systems as the original contributor of this module. + * All other licensing and usage conditions are those of the Apache Group. + * + * Some of this code is derived from the free version of the file command + * originally posted to comp.sources.unix. Copyright info for that program + * is included below as required. + * --------------------------------------------------------------------------- + * - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin. + * + * This software is not subject to any license of the American Telephone and + * Telegraph Company or of the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on any + * computer system, and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The author is not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, credits + * must appear in the documentation. + * + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users ever read + * sources, credits must appear in the documentation. + * + * 4. This notice may not be removed or altered. + * ------------------------------------------------------------------------- + * + */ + + +For the modules\mappers\mod_imagemap.c component: + + "macmartinized" polygon code copyright 1992 by Eric Haines, erich@eye.com + +For the server\util_md5.c component: + +/************************************************************************ + * NCSA HTTPd Server + * Software Development Group + * National Center for Supercomputing Applications + * University of Illinois at Urbana-Champaign + * 605 E. Springfield, Champaign, IL 61820 + * httpd@ncsa.uiuc.edu + * + * Copyright (C) 1995, Board of Trustees of the University of Illinois + * + ************************************************************************ + * + * md5.c: NCSA HTTPd code which uses the md5c.c RSA Code + * + * Original Code Copyright (C) 1994, Jeff Hostetler, Spyglass, Inc. + * Portions of Content-MD5 code Copyright (C) 1993, 1994 by Carnegie Mellon + * University (see Copyright below). + * Portions of Content-MD5 code Copyright (C) 1991 Bell Communications + * Research, Inc. (Bellcore) (see Copyright below). + * Portions extracted from mpack, John G. Myers - jgm+@cmu.edu + * Content-MD5 Code contributed by Martin Hamilton (martin@net.lut.ac.uk) + * + */ + + +/* these portions extracted from mpack, John G. Myers - jgm+@cmu.edu */ +/* (C) Copyright 1993,1994 by Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Carnegie + * Mellon University not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. Carnegie Mellon University makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) + * + * Permission to use, copy, modify, and distribute this material + * for any purpose and without fee is hereby granted, provided + * that the above copyright notice and this permission notice + * appear in all copies, and that the name of Bellcore not be + * used in advertising or publicity pertaining to this + * material without the specific, prior written permission + * of an authorized representative of Bellcore. BELLCORE + * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY + * OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", + * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. + */ + +For the srclib\apr\include\apr_md5.h component: +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +For the srclib\apr\passwd\apr_md5.c component: + +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ +/* + * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0 + * MD5 crypt() function, which is licenced as follows: + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + */ + +For the srclib\apr-util\crypto\apr_md4.c component: + + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +For the srclib\apr-util\include\apr_md4.h component: + + * + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + + +For the srclib\apr-util\test\testmd4.c component: + + * + * This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All + * rights reserved. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +For the srclib\apr-util\xml\expat\conftools\install-sh component: + +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# + +For the srclib\pcre\install-sh component: + +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. + +For the pcre component: + +PCRE LICENCE +------------ + +PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + +Release 5 of PCRE is distributed under the terms of the "BSD" licence, as +specified below. The documentation for PCRE, supplied in the "doc" +directory, is distributed under the same terms as the software itself. + +Written by: Philip Hazel + +University of Cambridge Computing Service, +Cambridge, England. Phone: +44 1223 334714. + +Copyright (c) 1997-2004 University of Cambridge +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +End PCRE LICENCE + + +For the test\zb.c component: + +/* ZeusBench V1.01 + =============== + +This program is Copyright (C) Zeus Technology Limited 1996. + +This program may be used and copied freely providing this copyright notice +is not removed. + +This software is provided "as is" and any express or implied waranties, +including but not limited to, the implied warranties of merchantability and +fitness for a particular purpose are disclaimed. In no event shall +Zeus Technology Ltd. be liable for any direct, indirect, incidental, special, +exemplary, or consequential damaged (including, but not limited to, +procurement of substitute good or services; loss of use, data, or profits; +or business interruption) however caused and on theory of liability. Whether +in contract, strict liability or tort (including negligence or otherwise) +arising in any way out of the use of this software, even if advised of the +possibility of such damage. + + Written by Adam Twiss (adam@zeus.co.uk). March 1996 + +Thanks to the following people for their input: + Mike Belshe (mbelshe@netscape.com) + Michael Campanella (campanella@stevms.enet.dec.com) + +*/ + +For the expat xml parser component: + +Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + and Clark Cooper + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +====================================================================