'encoding UTF-8 Do not remove or change this line! '************************************************************************** ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ' ' Copyright 2000, 2010 Oracle and/or its affiliates. ' ' OpenOffice.org - a multi-platform office productivity suite ' ' This file is part of OpenOffice.org. ' ' OpenOffice.org is free software: you can redistribute it and/or modify ' it under the terms of the GNU Lesser General Public License version 3 ' only, as published by the Free Software Foundation. ' ' OpenOffice.org is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU Lesser General Public License version 3 for more details ' (a copy is included in the LICENSE file that accompanied this code). ' ' You should have received a copy of the GNU Lesser General Public License ' version 3 along with OpenOffice.org. If not, see ' ' for a copy of the LGPLv3 License. ' '/************************************************************************ '* '* owner : oliver.craemer@oracle.com '* '* short description : selecting objects in calc '* '************************************************************************************************** '* ' #1 fCalcSelectRange ' #1 fCalcNameRange ' #1 fCalcSelectCell ' #1 fCalcGetSelectionString ' #1 fCalcSelectSheet ' #1 fNavigatorSelectObject '* '\************************************************************************************************ function fCalcSelectRange ( sSelectThis ) as boolean '///Select a range in calc and check success '///+Valid cell reference and name should work here '///+RETURNS: BOOLEAN fCalcSelectRange = FALSE '/// '------------------------------------------------------------------------- function fCalcNameRange ( sNameThis ) as boolean '///This is just an alias function to avoid confusion -> see 'fCalcSelectRange' '///With the integration of CWS 'rangename' the function 'fCalcSelectRange' '///+could also be used to name a previous selected range fCalcNameRange = fCalcSelectRange ( sNameThis ) end function ' '-------------------------------------------------------------------- ' function fCalcSelectCell ( sSelectThisCell ) as boolean '///This is just an alias function to avoid confusion -> see 'fCalcSelectRange' fCalcSelectCell = fCalcSelectRange ( sSelectThisCell ) end function ' '-------------------------------------------------------------------- ' function fCalcGetSelectionString() as String '///Obtain range (e.g. 'A1:E10') or range name in 'formula bar' '///+RETURNS: STRING/// '///
    '///
  • Check if 'formula bar' is visible
  • /// Kontext "RechenleisteCalc" if not RechenleisteCalc.isvisible then '///
  • -> Throw warning and Invoke 'formula bar' if invisible
  • /// '///
  • -> NOTE: The testcase developer has to take care herself that function is entered correctly
  • /// warnlog "Formula bar was expected to be visible" ViewToolbarsFormulaBar end if sleep(2) '///
  • Get and return string in range selection list box
  • /// Kontext "RechenleisteCalc" fCalcGetSelectionString = Bereich.GetSelText '///
end function ' '-------------------------------------------------------------------- ' function fCalcSelectSheet ( sSelectThisSheet ) as boolean '///Select a sheet by name (STRING) or number (INTEGER)/// '///+RETURNS: boolean (success)/// fCalcSelectSheet = FALSE '///
    try Kontext "DocumentCalc" '///
  • Invoke Edit::Sheet::Select
  • /// EditSheetSelect Kontext "SelectSheets" '///
  • Select sheet no. or sheet name in listbox
  • /// SheetSelectionBox.Select ( sSelectThisSheet ) '///
  • OK
  • /// SelectSheets.OK '///
  • Return true
  • /// fCalcSelectSheet = TRUE catch warnlog "Something went wrong while selecting a sheet by name" '///
  • In case of failture lookup 'Select sheets' dialog andd close it if exists
  • /// Kontext "SelectSheets" if SelectSheets.exists(2) then SelectSheets.Cancel end if endcatch '///
end function ' '------------------------------------------------------------------------- ' function fNavigatorSelectObject ( sWhatObject as STRING , iObjectPosition as INTEGER ) '///Select any Object in Navigator '///STRING: sWhatObject - A keyword to choose desired obeject category '///+Posible values: sheets, range names, database ranges, linked areas, graphics, ole objects, notes, drawing objects '///INTEGER: iObjectPosition - Position of object (>=1) within 'sWhatObject' '///+NOTE:You're moving within a treelistbox which is quite messy to handle. '///+In case 'iObjectPosition' is larger than the real number of objects in category you're end up in another categories. '///+WITHOUT ANY WARNING! '///RETURNS: BOOLEAN (success)
'///----- '///
    dim bNavigatorWasVisible as boolean bNavigatorWasVisible = FALSE dim iIndex dim iCategoryPosition as INTEGER fNavigatorSelectObject = FALSE '///
  • Translate 'sWhatObject' to postion number of desired object category
  • /// select case lcase ( sWhatObject ) case "sheets" : iCategoryPosition = 1 case "range names" : iCategoryPosition = 2 case "database ranges" : iCategoryPosition = 3 case "linked areas" : iCategoryPosition = 4 case "graphics" : iCategoryPosition = 5 case "ole objects" : iCategoryPosition = 6 case "notes" : iCategoryPosition = 7 case "drawing objects" : iCategoryPosition = 8 case else warnlog "Invalid keyword -> Aborting fNavigatorSelectObject()" exit function end select '///
  • Check if Navigator is visible
  • /// Kontext "NavigatorCalc" if NavigatorCalc.exists (3) then '///
  • Remember state of visibiliy TRUE/FALSE
  • /// bNavigatorWasVisible = TRUE else '///
  • Invoke navigator if not visible
  • /// ViewNavigator end if try Kontext "NavigatorCalc" '///
  • Go to Top in Navigator
  • /// liste.TypeKeys "" '///
  • Travel top to bottom through all categories
  • /// for iIndex = 1 to 8 '///
  • Make sure all elements in category are hidden, apply '-' key
  • /// liste.TypeKeys "-" next iIndex '///
  • Select desired category
  • /// liste.select ( iCategoryPosition ) '///
  • Unfold elements of selected category
  • /// liste.TypeKeys "+" '///
  • Select desired position within category
  • /// liste.select ( iCategoryPosition + iObjectPosition ) '///
  • Hit 'RETURN' key to select element in document
  • /// liste.TypeKeys "" '///
  • Return 'TRUE' for 'fNavigatorSelectObject'
  • /// fNavigatorSelectObject = TRUE catch warnlog "Selecting the desired object failed. Perhaps your input wasn't valid" endcatch '///
  • Close navigator if it wasn't visible before entering this function
  • /// if bNavigatorWasVisible = TRUE then printlog "Leaving navigator open as initially found" else ViewNavigator printlog "Closing navigator as initially found" end if '///
end function