Andreas Saeger wrote:
1. objCell.getType() returns a
c.s.s.sheet.CellContentType.EMPTY|VALUE|TEXT|FORMULA

2. objCell.getFormula() returns the formula string (not nesessarily a
formula. It's the "stored english cell-content" like "=SUM(A1:B5)",
"0.5" or "abcd").

3. objCell.getError() = 0 if the formula result is not an error.

4. objCell.queryFormulaCells(c.s.s.sheet.FormulaResult.STRING|VALUE)
returns a collection of one or zero single range when called from a
single cell. c.s.s.sheet.FormulaResult.ERROR fails due to a known issue
58749, but we can use method 3.

I found another solution for that problem too. XCellRangeData returns an Object[] array which consists of Double/String, so I can simply use that (I didn't recognize that at first, as "Range" didn't particularly make sense for a single cell. But as I know now, even a single cell implements that interface.)

So you can test if the cell has any formula [1], if the formula includes
something like com.sun.star.calc.your_Addin.getSomething(*) [2].
If it has no error[3], but includes an element of text or numeric
formula result[4], then you can get the "real value" by
objCell.getString() or objCell.getValue() respectively.
Finally you can search for sub-string
com.sun.star.calc.your_Addin.getSomething(*) and call your add-in
function after evaluating the arguments.
You need a parser which is able to resolve string-references:
- SheetX.A1:B5 with all possible "$" included (OK, no big deal)
- 'Sheet X'.A1:B5 (still no big deal if you know that the apostrophes
are not part of the sheet name)
- 'file:///path/doc/foo.xls'#SheetX.A1:B5 where
'file:///path/doc/foo.xls'#SheetX (including the apostrophes!) is the
name of a hidden import sheet.
- NamedRange objNamed.getReferredCells() returns Null if the range is
relative by any means. Only a full absolutized [$SheetX].$A$1:$B$5
returns any range. If the sheet name is missing completely, the name
refers to a range on this sheet. Unfortunatly,
objNamed.getReferredCells() always returns a range from sheet(0) in this
particular case (yes, I agree. This API is close to unusable).
- NamedDatabaseRange objNamed.getReferredCells() always returns a range
since database ranges are specified by an absolute range address.

Now that you mention it, my parser doesn't handle all these cases. But for now that should do the job.

Have a look at this: http://www.oooforum.org/forum/viewtopic.phtml?t=61265
Different problem, but similar issues.

Thanks, I'll take a look at that too.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to