/usr/share/octave/packages/io-2.4.5/private/__UNO_getusedrange__.m is in octave-io 2.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ## Copyright (C) 2011-2016 Philip Nienhuis
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program 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 General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## __UNO_getusedrange__
## Author: Philip Nienhuis <prnienhuis@users.sf.net>
## Created: 2011-05-06
function [ srow, erow, scol, ecol ] = __UNO_getusedrange__ (ods, ii)
# Get desired sheet
sheets = ods.workbook.getSheets ();
sh_names = sheets.getElementNames ();
unotmp = javaObject ("com.sun.star.uno.Type", "com.sun.star.sheet.XSpreadsheet");
sh = sheets.getByName (sh_names(ii)).getObject.queryInterface (unotmp);
## Prepare cell range query
unotmp = javaObject ("com.sun.star.uno.Type", "com.sun.star.sheet.XCellRangesQuery");
xRQ = sh.queryInterface (unotmp);
Cellflgs = javaObject ("java.lang.Short", "23");
ccells = xRQ.queryContentCells (Cellflgs);
## Get addresses of all blocks containing data
addrs = ccells.getRangeAddressesAsString ();
## Strip sheet name from addresses. Watch out, in LO3.5 they changed
## the separator from ',' to ';' (without telling me 8-Z)
## 1. Get nr of range blocks
nblks = numel (strfind (addrs, sh_names(ii)));
## 2. First try with "," separator...
adrblks = strsplit (addrs, ",");
if (numel (adrblks) < nblks)
## Apparently we have a ';' separator, so try with semicolon
adrblks = strsplit (addrs, ";");
endif
if (isempty (adrblks) || isempty (adrblks{1}))
srow = erow = scol = ecol = 0;
return
endif
## Find leftmost & rightmost columns, and highest and lowest row with data
srow = scol = 1e10;
erow = ecol = 0;
for ii=1:numel (adrblks)
## Check if address contains a sheet name in quotes (happens if name contains a period)
if (int8 (adrblks{ii}(1)) == 39)
## Strip sheet name part
idx = findstr (adrblks{ii}, "'.");
range = adrblks{ii}(idx+2 : end);
else
## Same, but tru strsplit()
range = strsplit (adrblks{ii}, "."){2};
endif
[dummy, nrows, ncols, trow, lcol] = parse_sp_range (range);
brow = trow + nrows - 1;
rcol = lcol + ncols - 1;
srow = min (srow, trow);
scol = min (scol, lcol);
erow = max (erow, brow);
ecol = max (ecol, rcol);
endfor
endfunction
|