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 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: c_cell_tools.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 08:06:09 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org. If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* owner : oliver.craemer@sun.com
36 '* short description : tools for working with cells in calc
38 '**************************************************************************************************
40 ' #1 fCalcGetCellValue 'Returns the value of a given cell
41 ' #1 fCalcCompareCellValue 'Compares the value of a given cell with a given result
42 ' #1 fCalcCompareCellFormular 'Compares the formular of a cell with a given result
44 '\************************************************************************************************
46 function fCalcGetCellValue ( sCelladdress as string ) as string
48 '///<b>The function returns the content of a given cell</b>
49 '///+The cell is selected by fCalcSelectRange which is located in /spreadsheet/tools/includes/c_select_tools.inc
50 '///+The content is copied to the clipboard by slot EditCopy
51 '///+ and read out by GetClipboardText which is located in /global/tools/inc/t_tools1.inc
52 use "spreadsheet\tools\includes\c_select_tools.inc"
53 use "global\tools\includes\required\t_tools1.inc"
55 call fCalcSelectRange (sCelladdress) 'Select the given cell
56 kontext "DocumentCalc" 'Setting kontext to Calcdocument
57 EditCopy 'Copy content to clipboard
58 fCalcGetCellValue = GetClipboardText 'Returning clipboard to function
62 '-------------------------------------------------------------------------
64 function fCalcCompareCellValue ( sCelladdress as string, sresult as string ) as boolean
66 '///<b>The function compares the value of a cell with a given result</b>
67 '///+The cellvalue is read by fCalcGetCellValue which is located in /spreadsheet/tools/includes/c_cell_tools.inc
68 '///+The value is compared with a given result (input)
69 '///+The function returns true if the comparison is correct and false for incorrect
71 if fCalcGetCellValue ( sCelladdress ) = sresult then
72 printlog " The cellvalue is correct"
73 fCalcCompareCellValue = true
75 warnlog "The cellvalue is " & fCalcGetCellValue ( sCelladdress ) & " but should be " & sresult
76 fCalcCompareCellValue = false
81 '-------------------------------------------------------------------------
83 function fCalcCompareCellFormular ( sCelladdress as string, sresult as string ) as boolean
85 '///<b>The function compares the formular of a cell with a given result</b>
86 '///+The value is compared with a given result (input)
87 '///+The function returns true if the comparison is correct and false for incorrect
89 dim sfunctionwithparameter as string
91 call fCalcSelectRange (sCelladdress)
92 kontext ( "RechenleisteCalc" )
93 EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
95 sfunctionwithparameter = GetClipboardText ()
96 '/// Press twice <ESCAPE> to leave the cell
97 'printlog "Press twice <ESCAPE> to leave the cell"
98 kontext ( "DocumentCalc" )
99 DocumentCalc.TypeKeys "<ESCAPE>" , 2
100 if sfunctionwithparameter = sresult then
101 printlog " The function is correct"
102 fCalcCompareCellFormular = true
104 warnlog "The function is " & sfunctionwithparameter & " instead of " & sresult
105 fCalcCompareCellFormular = false