I have been working on adding multiline formulae support and have
attached a patch to bug #35913. It also fixes bug #83666. A quick
summary of what it adds is the display of new lines when the result of a
formula contains a newline character. Previously, the newline characters
were filtered away and converted into spaces.
Some notable changes that the patch adds is:
- Copying text out of a cell containing multiple lines (an ScEditCell)
and pasting into a text editor like gvim will keep the newline
characters, previously the newlines were converted to spaces.
- Similarly for formula cells (ScFormulaCell).
- When entering/modifying a formula that results in more than one line,
the cell will automatically be resized to the optimal height, like when
entering multiple lines in an edit cell using CTRL-ENTER.
- Double clicking the horizontal bar between row numbers to auto-size
the row will size the row correctly to the optimal height (like it does
for a row with a ScEditCell containing multiple lines)
- Using char(10) in a formula will correctly display a newline
(previously it filtered it out completely)
- Newlines in the result of a formula are now available from Basic using
the cell's 'String' property.
Previously multiline support was inferior to Excel and Gnumeric. Now I
feel it is superior to Excel in some ways due to the autoresizing of the
row height when the result contains multiple lines. The fact that
char(10) does not work in Excel will also be a point in our favour.
Some potential issues:
- Compatibility with Excel possibly needs discussing. We've not been
compatible with Excel in the past and this patch does not make it 100%
compatible, rather it improves compatibility, and improves further where
Excel gets it wrong IMHO. I've chosen to show the newlines by default,
whereas this is impossible in Excel unless the "Wrap text" option is
ticked in the Format Cells dialog. To me the Excel behaviour is
incorrect as the option turns on newline display as well as wrapping the
contents, so it is doing something more than what it advertises - it
mixes formatting with content display. The behaviour in Calc showing new
lines is now consistent between ScFormulaCell and ScEditCell.
- Spreadsheets created in OpenOffice.org 2 *might* look different *if*
the result of a formula contains a newline.
- Performance. The patch could be made more performant by searching for
'\n' just once in the formula result and caching the result somewhere,
see the new method ScFormulaCell::IsMultilineResult(). I'm not sure if
this is really necessary though.
Everything else that I can see just works as you'd hope, for example
matrix cells as well as "Shrink to fit cell size", "Wrap text
automatically" in the Alignment tab of the Format Cells properties
dialog. This is largely because the patch simply uses the edit engine to
display the formula result if (and only if) the formula result contain
multiple lines.
I havn't yet figured out the Calc regression testing to make sure that
nothing else is broken. If it is easy for someone to run the tests with
the patch or point me in the right direction that would be much
appreciated. I've been developing and testing under Linux and have also
sent off my signed SCA.
William
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]