1 'encoding UTF-8 Do not remove or change this line!
2 '**************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 ' Copyright 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '* owner : oliver.craemer@oracle.com
30 '* short description : tools for working with cells in calc
32 '**************************************************************************************************
34 ' #1 fCalcGetCellValue 'Returns the value of a given cell
35 ' #1 fCalcCompareCellValue 'Compares the value of a given cell with a given result
36 ' #1 fCalcCompareCellFormular 'Compares the formular of a cell with a given result
38 '\************************************************************************************************
40 function fCalcGetCellValue ( sCelladdress as string ) as string
42 '///<b>The function returns the content of a given cell</b>
43 '///+The cell is selected by fCalcSelectRange which is located in /spreadsheet/tools/includes/c_select_tools.inc
44 '///+The content is copied to the clipboard by slot EditCopy
45 '///+ and read out by GetClipboardText which is located in /global/tools/inc/t_tools1.inc
46 use "spreadsheet\tools\includes\c_select_tools.inc"
47 use "global\tools\includes\required\t_tools1.inc"
49 call fCalcSelectRange (sCelladdress) 'Select the given cell
50 kontext "DocumentCalc" 'Setting kontext to Calcdocument
51 EditCopy 'Copy content to clipboard
52 fCalcGetCellValue = GetClipboardText 'Returning clipboard to function
56 '-------------------------------------------------------------------------
58 function fCalcCompareCellValue ( sCelladdress as string, sresult as string ) as boolean
60 '///<b>The function compares the value of a cell with a given result</b>
61 '///+The cellvalue is read by fCalcGetCellValue which is located in /spreadsheet/tools/includes/c_cell_tools.inc
62 '///+The value is compared with a given result (input)
63 '///+The function returns true if the comparison is correct and false for incorrect
65 if fCalcGetCellValue ( sCelladdress ) = sresult then
66 printlog " The cellvalue is correct"
67 fCalcCompareCellValue = true
69 warnlog "The cellvalue is " & fCalcGetCellValue ( sCelladdress ) & " but should be " & sresult
70 fCalcCompareCellValue = false
75 '-------------------------------------------------------------------------
77 function fCalcCompareCellFormular ( sCelladdress as string, sresult as string ) as boolean
79 '///<b>The function compares the formular of a cell with a given result</b>
80 '///+The value is compared with a given result (input)
81 '///+The function returns true if the comparison is correct and false for incorrect
83 dim sfunctionwithparameter as string
85 call fCalcSelectRange (sCelladdress)
86 kontext ( "RechenleisteCalc" )
87 EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
89 sfunctionwithparameter = GetClipboardText ()
90 '/// Press twice <ESCAPE> to leave the cell
91 'printlog "Press twice <ESCAPE> to leave the cell"
92 kontext ( "DocumentCalc" )
93 DocumentCalc.TypeKeys "<ESCAPE>" , 2
94 if sfunctionwithparameter = sresult then
95 printlog " The function is correct"
96 fCalcCompareCellFormular = true
98 warnlog "The function is " & sfunctionwithparameter & " instead of " & sresult
99 fCalcCompareCellFormular = false