Issue 35913 - reference to content with explicit newlines in cells
Summary: reference to content with explicit newlines in cells
Status: CLOSED FIXED
Alias: None
Product: Calc
Classification: Application
Component: ui (show other issues)
Version: OOo 1.1.3
Hardware: All All
: P2 Trivial with 22 votes (vote)
Target Milestone: ---
Assignee: oc
QA Contact: issues@sc
URL:
Keywords: regression
: 18302 30781 95444 95452 (view as issue list)
Depends on:
Blocks: 15339 83666
  Show dependency tree
 
Reported: 2004-10-21 09:17 UTC by klausthomas
Modified: 2013-08-07 15:14 UTC (History)
12 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
reference to cells with newlines (5.01 KB, application/vnd.sun.xml.calc)
2004-10-21 09:20 UTC, klausthomas
no flags Details
Patch to fix this bug against DEV300_m16 (6.41 KB, patch)
2008-07-30 14:42 UTC, wsfulton
no flags Details | Diff
Spreadsheet demonstrating the various multi-line improvements (11.26 KB, text/plain)
2008-08-03 23:15 UTC, wsfulton
no flags Details
Screenshot of MultilinePatchShowcase.ods without the patch (133.10 KB, image/png)
2008-08-03 23:17 UTC, wsfulton
no flags Details
Screenshot of MultilinePatchShowcase.ods with the patch (130.87 KB, image/png)
2008-08-03 23:19 UTC, wsfulton
no flags Details
original patch plus further improvements, details to follow... (17.01 KB, patch)
2008-08-17 23:18 UTC, wsfulton
no flags Details | Diff
Here is the patch with the odf issue fixed. (18.66 KB, patch)
2008-08-24 06:24 UTC, kyoshida
no flags Details | Diff
updated patch (21.47 KB, patch)
2008-09-18 23:18 UTC, kyoshida
no flags Details | Diff
a little more updated to check if the cell is a formula cell before checking for its multi-line state. (21.54 KB, patch)
2008-09-18 23:35 UTC, kyoshida
no flags Details | Diff
Eike's unsigned char suggestion added and removed warning introduced in ScXMLExport::IsMultiLineFormulaCell (22.79 KB, patch)
2008-09-19 13:35 UTC, wsfulton
no flags Details | Diff
Further multiline improvements (40.17 KB, patch)
2008-11-08 23:15 UTC, wsfulton
no flags Details | Diff
multilines5.patch (47.14 KB, patch)
2009-03-05 22:18 UTC, wsfulton
no flags Details | Diff
multilines6.patch (47.05 KB, text/plain)
2009-03-05 23:31 UTC, wsfulton
no flags Details
Test (88.50 KB, text/plain)
2009-09-03 15:49 UTC, vitriol
no flags Details
Fix multiline formula regression in output2.cxx (779 bytes, text/plain)
2009-09-06 10:23 UTC, wsfulton
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description klausthomas 2004-10-21 09:17:35 UTC
I want to use explicit newlines (CTRL+Return) in cells and reference this cell
with newlines in it (e.g. B1: =A1), all the newlines are deleted

The Input of:
         A          |       B
1   one\ntwo\nthree |      =A1
2                   |

results in:
         A          |       B
1   one\ntwo\nthree |  one two three
2                   |

All the newline are replaced with spaces.
Comment 1 klausthomas 2004-10-21 09:20:32 UTC
Created attachment 18578 [details]
reference to cells with newlines
Comment 2 frank 2004-10-21 10:04:18 UTC
Hi,

as we mostly (we do display spaces between the single lines, Excel shows them in
a single line without delimiter) act in the same way as Excel does, this is not
a defect.

As we are not able to add some linebreaks to such a reference, I'd like to see
this as an enhancement request. So re-flagged and re-assigned.

Frank
Comment 3 fremandn 2004-10-29 04:48:18 UTC
I am using OOo. 1.9m56: on winxp home edition. I am using \n to indicate newline

1. When I enter 1 "newline" 2 ""newline" 3 "newline" in a cell, it displays
properly.
___
   1|
   2|
   3|
----|

2. When I copy and paste the cell staying within the same spreadsheet. (selected
outline cell in black, right click etc.) It copies fine. If I copy as before
into another application though, it is now spaced out, not newlined properly.
3. If I copy and paste the cell contents by selecting the text within (double
clicking) the cell (not to be confused with the input line at top). It copies
each entry as a new cell. If I do this, but paste into notepad instead, they are
newlined correctly.
4. If I select the cell and then right click on the input bar (where it displays
the 1 2 3 uptop)
*\dramatic pause\*
The actual cell entry changes into spaced numbers!!!!!!!!! They continue to
behave in this manner (1 2 3 not 1\n 2\n 3\n) even when copied out to notepad.


I have had similar results in OOo  1.1.2 WinXP home ed.
(I have both OOo 1.1.2 and OOo 1.9m56 installed if that matters)
My friend has reproduced this in OOo 1.1.0  on SuSE 9.0 Prof. Linux 2.6.7,
instead of notepad he used Kate. 
Comment 4 berteh 2006-07-05 17:32:36 UTC
Besides the simple preservation of these \n when referencing a cell (and any
format in general, like italics or bold parts of texts), I'd like to have it
preserved when the spreadsheet is used as a database (in Base), and then
imported in Writer (using mailing function). That would make OOo even more powerful!


Comment 5 wsfulton 2008-07-30 14:42:06 UTC
Created attachment 55450 [details]
Patch to fix this bug against DEV300_m16
Comment 6 wsfulton 2008-07-30 14:43:47 UTC
I've attached a patch to fix the reported problem. The patch also fixes #83666.

Summary of notable changes that the patch adds:
- 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
(after a manual resizing) will size the row correctly to the optimal height
(like it does for an 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.
Comment 7 wsfulton 2008-08-02 23:04:40 UTC
Issue 14558 is also fixed by the attached patch.
Comment 8 wsfulton 2008-08-03 20:42:28 UTC
Issue 15339 (VLOOKUP regular expressions involving \n) is also fixed by the patch.
Comment 9 wsfulton 2008-08-03 23:09:23 UTC
The patch also fixes some regular expression problems. The Find and Replace
dialog will now match correctly for the results of formulae when selecting
"Regular expressions" and the "Search in" option is set to "Values", eg
searching for "\n" or "^abc$" or "bc\nde" will now match both A1 and A2 below,
previously just A1 matched:

A1:
abc
def

A2:
=A1

I also tried the COUNTIF, SUMIF and SEARCH formulae (as they support regex) with
the above search patterns and these also now give consistent results, ie the
results are the same when these formulae operate on either A1 or A2 above.
Comment 10 wsfulton 2008-08-03 23:15:31 UTC
Created attachment 55515 [details]
Spreadsheet demonstrating the various multi-line improvements
Comment 11 wsfulton 2008-08-03 23:17:56 UTC
Created attachment 55516 [details]
Screenshot of MultilinePatchShowcase.ods without the patch
Comment 12 wsfulton 2008-08-03 23:19:03 UTC
Created attachment 55517 [details]
Screenshot of MultilinePatchShowcase.ods with the patch
Comment 13 ooo 2008-08-08 11:34:46 UTC
FYI: discussion of this patch takes place on the dev@sc mailing list.
Comment 14 wsfulton 2008-08-10 00:15:00 UTC
Could someone with appropriate permissions mark the following as also being
duplicates of this bug or fixed by the patch:

Issue 18302 and all duplicates assigned to it.
Issue 50000 line feed aspect.
Issue 30781 and the duplicates assigned to it.
Issue 5250.
Comment 15 erack 2008-08-10 17:01:04 UTC
*** Issue 18302 has been marked as a duplicate of this issue. ***
Comment 16 erack 2008-08-10 17:05:54 UTC
*** Issue 30781 has been marked as a duplicate of this issue. ***
Comment 17 erack 2008-08-10 17:13:44 UTC
Issue 50000 and issue 5350 are not duplicates of this issue, they describe
something different.
Comment 18 wsfulton 2008-08-11 09:40:06 UTC
Issue 5250 (not 5350) is similar to this one. I apologise, but on rechecking,
the patch does not actually fix it.
However, issue 50000 describes a line feed problem amongst many others, and this
aspect is fixed by the patch.
Comment 19 ooo 2008-08-11 18:08:05 UTC
Of course 5350 was a typo.. anyway, issue 5250 is not a duplicate, it is
about entering a formula with newlines such that the formula would look
like

=expression1
+expression2

when the formula is edited. This is not possible, the cell created in
this case is an ScEditCell and thus loses formula functionality, and
is not covered by this patch.

The one aspect of linefeed in issue 50000 indeed would be fixed with
this patch, but the underlying problem of that issue is something
completely different.
Comment 20 wsfulton 2008-08-17 23:18:46 UTC
Created attachment 55814 [details]
original patch plus further improvements, details to follow...
Comment 21 wsfulton 2008-08-17 23:20:28 UTC
Additional changes to first patch:
xestyle.hxx xestyle.cxx xetable.cxx - Excel xls export converter, "wrap text"
turned on for formula cells like it is for non-formula cells
cell.hxx cell.cxx formularesult.hxx - Eike Rathke suggestions on the original
patch to improve performance
column3.cxx -  Fixes for Copy, Paste Special, untick formula, ie paste text only
from a formula with multilines
transobj.cxx - Calc8 OLE linking and embedding multiline formula fixes
impex.cxx - Save as SYLK with multilines
Comment 22 kami911 2008-08-22 16:08:59 UTC
Is this patch work well? Any possible regression?
Kohei:  If you agree I'll integrate it into ooo-build system.
Comment 23 kyoshida 2008-08-22 16:18:01 UTC
@kami_: well, I don't agree yet.  Since this will affect file export, we need to
do a thorough testing to make sure import/export works.  I'm mostly interested
in xls/ods file import/export.  Niklas mentioned one potential issue about ods
file import/export on the dev@sc list.  So we need to at least look into that
before we can use this patch.
Comment 24 kyoshida 2008-08-22 16:47:30 UTC
@kami_: either that, or wait until we branch ooo-build for 3.0, then you can put
the patch in trunk for testing.
Comment 25 kyoshida 2008-08-24 06:05:31 UTC
Ok.  I just ran a quick test, and the patch seems to work pretty well all
around.  I saw the issue with ODS export that Niklas mentioned.  Yes, it works
with the line breaks but we should be consistent with the output of a text cell
and use <text:p> there in the formula cell output.  Luckily it's an easy fix, so
I'll see if I can take care of that there.
Comment 26 kyoshida 2008-08-24 06:20:14 UTC
One thing I noticed, when exporting to SYLK format, Excel has trouble importing
the cell reference =A1 due to "name conflict", and Calc has trouble importing
the encoded LF character.  But that's probably a bug in Calc's SYLK importer so
it's not the fault of this patch.

(Besides, who uses SYLK these days?)
Comment 27 kyoshida 2008-08-24 06:24:30 UTC
Created attachment 55967 [details]
Here is the patch with the odf issue fixed.
Comment 28 kyoshida 2008-08-24 06:27:51 UTC
One minor point.  Since the difference between
ScEditUtil::GetSpaceDelimitedString() and ScEditUtil::GetMultilineString() was
just the delimiter character, I moved the common part to a local function to
eliminate duplicated code.
Comment 29 niklas.nebel 2008-09-18 18:19:15 UTC
Some problems:

- Conversion to unformatted text still unconditionally includes the LF
character, regardless of the system's line delimiter. For the clipboard, where
we don't use text delimiters (quotes), including any line delimiter will break
the table structure.

- Eike's suggestion "Multiline meMultiline : 2" doesn't work with MSVC, because
it uses (signed) int as the default underlying type for enums.

- Kohei's change, with ScXMLExport::IsMultiLineFormulaCell always calling
ScDocument::GetCell, adds some performance overhead. I didn't measure it, but
load/save is something we don't want to slow down (at least if multiple-line
formula results aren't used).
Comment 30 kyoshida 2008-09-18 23:19:00 UTC
Created attachment 56621 [details]
updated patch
Comment 31 kyoshida 2008-09-18 23:26:42 UTC
I've updated the patch to address the 2nd and 3rd issues that nn raised.

> - Eike's suggestion "Multiline meMultiline : 2" doesn't work with MSVC, because
> it uses (signed) int as the default underlying type for enums.

I simply removed the trailing :2 size specifier.  Will this be enough?  We 
(William and I) don't seem to have a good Windows develoment environment, so 
any suggestion for this would be appreciated if this change will not be 
adequate.

> - Kohei's change, with ScXMLExport::IsMultiLineFormulaCell always calling
> ScDocument::GetCell, adds some performance overhead. I didn't measure it, but
> load/save is something we don't want to slow down (at least if multiple-line
> formula results aren't used).

I've made some change so that ScDocument::GetCell() gets called only once.
Comment 32 kyoshida 2008-09-18 23:35:59 UTC
Created attachment 56622 [details]
a little more updated to check if the cell is a formula cell before checking for its multi-line state.
Comment 33 ooo 2008-09-19 11:23:53 UTC
> > - Eike's suggestion "Multiline meMultiline : 2" doesn't work with MSVC, because
> > it uses (signed) int as the default underlying type for enums.
> 
> I simply removed the trailing :2 size specifier.  Will this be enough?

That would add 4 bytes to every formula cell of which 30 bit are
unused.. which was the reason I suggested to add to the bit field
instead where we have some unused space left. Better would be

    typedef unsigned char Multiline;
    const Multiline MULTILINE_UNKNOWN = 0;
    ...
    Multiline meMultiline :2;
Comment 34 wsfulton 2008-09-19 13:35:43 UTC
Created attachment 56639 [details]
Eike's unsigned char suggestion added and removed warning introduced in ScXMLExport::IsMultiLineFormulaCell
Comment 35 Regina Henschel 2008-10-25 21:37:03 UTC
*** Issue 95444 has been marked as a duplicate of this issue. ***
Comment 36 ooo 2008-10-29 12:42:42 UTC
*** Issue 95452 has been marked as a duplicate of this issue. ***
Comment 37 ooo 2008-10-29 12:45:30 UTC
@wsfulton: How's progress on testing and adapting all places that would be
affected by this change, or adapting the change, as discussed on the dev@sc
mailing list?
Comment 38 wsfulton 2008-10-30 20:21:15 UTC
@er, I have a Windows build environment working and as such have been able to
test interoperability better and test more filters. I have fixed various issues
and will post an intermediate patch soon. I don't think there is any obvious
route to take for fixing DDE links on Unix, but will post to the mailing list
when I've better understood the DDE implementation.
Comment 39 wsfulton 2008-11-08 23:15:01 UTC
Created attachment 57798 [details]
Further multiline improvements
Comment 40 wsfulton 2008-11-08 23:16:46 UTC
multilines4.patch improvements since the previous patch:

- Copy/paste text - add in quotes around the cell contents (string delimiter) if
cell text is multiline (like it does if string contains a tab): impex.cxx
- Export and paste as HTML fix for multiline text (both formula and non-formula
cells): htmlexp.cxx
- Fix multiline DIF format import and paste special (formula and non-formula
cells) for example when importing from Excel: dif.hxx difimp.cxx
- Fix SYLK import containing newlines - now OOo is compatible with Excel:
impex.cxx (Doc2Sylk and Sylk2Doc).
- Fix SYLK import/export containing the quote character (") and semicolon. The
escaping of these characters is now the same as other spreadsheets, I checked
Excel, Quattro Pro and Gnumeric. Fixes copy from OOo to Excel as Excel chooses
the SYLK format as the default when pasting from OOo. Note that this is only
noticeable if from the menu Tools, Autocorrect, Double Quotes, Custom Quotes,
Replace is not ticked. Note that this is ticked by default: impex.cxx
- Auto resize cell heights so multiline cells display correctly when importing
formats DIF and SYLK : docsh.cxx
- QuattroPro import filter fix for multi-line non-formula cells: qpro.cxx
Comment 41 ooo 2008-11-11 12:15:14 UTC
GREAT! I think this does it, does someone think differently?
Comment 42 wsfulton 2009-03-05 22:18:20 UTC
Created attachment 60759 [details]
multilines5.patch
Comment 43 wsfulton 2009-03-05 22:24:22 UTC
multilines5.patch - This patch contains the previous patch (multilines4.patch)
plus the following modifications:
- Newlines are converted into spaces for DDE linking as per discussion on
openoffice-sc-dev list in Nov 2008.
- Pasting cell contents as text into external application never adds quotes, ie
the pasting text behaviour of patch 4 is removed. The text is now pasted exactly
as stored in the cell, including newlines.
Files modified since previous patch: transobj.cxx, docsh4.cxx, impex.hxx,
impex.cxx, servobj.cxx, cellsh2.cxx
Comment 44 wsfulton 2009-03-05 23:31:33 UTC
Created attachment 60760 [details]
multilines6.patch
Comment 45 wsfulton 2009-03-05 23:33:52 UTC
multilines6.patch - This patch contains the previous patch (multilines5.patch)
plus the following modifications:
- Fixed DDE linking when a cell contains a tab - it gets converted to a space,
as per openoffice-sc-dev list discussion in Nov 2008.
Files modified since last patch: transobj.cxx, docsh4.cxx, impex.hxx, impex.cxx,
servobj.cxx, cellsh2.cxx
Comment 46 ooo 2009-03-06 12:52:27 UTC
I'll apply this to CWS calcmultiline.
Thanks again,
  Eike
Comment 47 rcabane 2009-03-06 14:56:55 UTC
Congratulations ! So nice to see that old problems are going away ! And many,
many thanks to the developers.
Robert
Comment 48 ooo 2009-03-10 18:19:05 UTC
In cws calcmultiline:

revision 269286
sc/inc/cell.hxx
sc/inc/editutil.hxx
sc/inc/formularesult.hxx
sc/source/core/data/cell.cxx
sc/source/core/data/cell2.cxx
sc/source/core/data/column.cxx
sc/source/core/data/column2.cxx
sc/source/core/data/column3.cxx
sc/source/core/tool/editutil.cxx
sc/source/filter/dif/difimp.cxx
sc/source/filter/excel/xestyle.cxx
sc/source/filter/excel/xetable.cxx
sc/source/filter/html/htmlexp.cxx
sc/source/filter/inc/dif.hxx
sc/source/filter/inc/xestyle.hxx
sc/source/filter/qpro/qpro.cxx
sc/source/filter/xml/XMLExportIterator.cxx
sc/source/filter/xml/XMLExportIterator.hxx
sc/source/filter/xml/xmlexprt.cxx
sc/source/filter/xml/xmlexprt.hxx
sc/source/ui/app/transobj.cxx
sc/source/ui/docshell/docsh.cxx
sc/source/ui/docshell/docsh4.cxx
sc/source/ui/docshell/impex.cxx
sc/source/ui/docshell/servobj.cxx
sc/source/ui/inc/impex.hxx
sc/source/ui/view/cellsh2.cxx
sc/source/ui/view/output2.cxx

Note that I changed ScXMLExport::IsMultiLineFormulaCell() and
ScFormulaResult::IsMultiline() to const methods, the latter mutating meMultiline
through a const_cast.
Comment 49 ooo 2009-03-12 16:47:48 UTC
Reassigning to QA for verification.
Comment 50 erack 2009-03-15 01:29:05 UTC
revision 269502
sc/source/ui/docshell/impex.cxx

Fixed a problem with string data followed by a formula expression containing
quoted constant string data. Something like
K"this data";EA1&" data"
lead to the expression being appended to the cell data.

Primarily the change fixes the overall handling of embedded quotes in formula
expressions, that incorrectly were escaped by doubling them, and embedded
semicolons, that incorrectly were not escaped. For details see issue 100205.
Comment 51 oc 2009-04-24 13:08:10 UTC
verified in internal build cws_calcmultiline
Comment 52 amy2008 2009-06-05 07:45:41 UTC
Verified in DEV300m49 on WinXP
Closing
Comment 53 vitriol 2009-09-03 15:47:36 UTC
This patch seems not working in version DEV300m56. See attached test image please.
What's wrong
Comment 54 vitriol 2009-09-03 15:49:25 UTC
Created attachment 64528 [details]
Test
Comment 55 vitriol 2009-09-03 16:51:02 UTC
I tested the DEV300m56 on a different Win system, and I got the same result. I
think that this issue should be reopened...

Thanks
Comment 56 cno 2009-09-04 11:57:31 UTC
also checked in M56 and can confirm the results from vitriol.
Comment 57 Stefan Weigel 2009-09-04 15:52:13 UTC
Reopening.

Issue *not* fixed in DEV300m56.

Comment 58 ooo 2009-09-04 16:03:39 UTC
@wsfulton: could you take a look what breaks this now? Must had been introduced
between m49 and m56.
Thanks.
Comment 59 wsfulton 2009-09-04 19:13:25 UTC
Sigh, I'll take a look.

If anyone checks any versions between m49 and m56 and that will help me a lot.
Comment 60 wsfulton 2009-09-04 22:27:16 UTC
I just checked m51 on Linux and multiline formulas are broken in this version.
Comment 61 wsfulton 2009-09-04 23:31:15 UTC
m50 works fine, so the problem was introduced in m51. A lot of the multiline
patch does actually work in m51, so it hasn't all been removed. It looks like
just the newline character is ignored when displaying formula results. The
formula does actually contain the newline as copy/paste as text from the formula
cell does retain the new line.
Comment 62 Regina Henschel 2009-09-04 23:36:26 UTC
I have tested m50 (build 9406) on WinXP. Multiline formulas are OK there.
Comment 63 wsfulton 2009-09-06 10:20:39 UTC
Regression is in output2.cxx revision 272382  on
http://svn.services.openoffice.org/ooo/cws/calc50/sc
with comment "CWS-TOOLING: rebase CWS calc50 to trunk@272291 (milestone:
DEV300:m49)"
Comment 64 wsfulton 2009-09-06 10:23:02 UTC
Created attachment 64570 [details]
Fix multiline formula regression in output2.cxx
Comment 65 wsfulton 2009-09-06 10:42:30 UTC
Sorry, correction to the point of regression, 272382 on calc50 was correct.

svn diff -r272983:272984
http://svn.services.openoffice.org/ooo/trunk/sc/source/ui/view/output2.cxx

shows the regression occurring, ie "CWS-TOOLING: integrate CWS fhawfixes1"
Comment 66 ooo 2009-09-06 19:08:11 UTC
@wsfulton: Many Thanks!

In cws dr69:

revision 275862
sc/source/ui/view/output2.cxx

Note that strangely there was an extraneous colon in the patch.
Comment 67 ooo 2009-09-06 19:12:57 UTC
Judging from the topic and other commits of CWS fhawfixes1 the commit of
output2.cxx was an error anyway.
Comment 68 niklas.nebel 2009-09-07 11:35:19 UTC
Already fixed again, see issue 104059.
Comment 69 ooo 2009-09-09 15:18:35 UTC
Reassigning to QA for verification.
Comment 70 oc 2009-09-11 16:37:41 UTC
verified in internal build cws_dr69
Comment 71 Raphael Bircher 2010-01-18 19:13:55 UTC
Tested with a MacBook with OSX 10.5.x on OOO320_m9

works as expected

closing issue