Summary: | Calc eats ' when the content is text. | ||
---|---|---|---|
Product: | LibreOffice | Reporter: | Kohei Yoshida <kohei> |
Component: | Calc | Assignee: | Katarina Behrens <bubli> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | caolan.mcnamara |
Priority: | high | ||
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | target:3.4 | ||
Crash report or crash signature: | Regression By: | ||
Attachments: | Proposed patch |
Description
Kohei Yoshida
2011-02-14 08:12:03 UTC
A good place to start would be ScViewFunc::EnterData() That method is overloaded with several variants. Pick the one that takes String as one of the arguments, and work your way down. Somewhere, somehow we may be eating the apostrophe... BTW Katarina, we've made a deal with Caolan that, in exchange for him fixing our favorite Writer bugs, we fix his favorite Calc bugs in earnest. And this is one of those bugs... :-) So, bumping up the priority for this would be well appreciated. ;-)
> BTW Katarina, we've made a deal with Caolan that, in exchange for him fixing
> our favorite Writer bugs, we fix his favorite Calc bugs in earnest. And this
> is one of those bugs... :-)
>
> So, bumping up the priority for this would be well appreciated. ;-)
Fair enough, bumping prio then
So far, string cells beginning with ' were treated as follows: ScColumn::SetString (column3.cxx) stored n-1 chars (everything but ' char) into ScStringCell object. Later, ScTabViewShell::UpdateInputHandler (tabvwsha.cxx) when re-constructing the string to show in the edit field, appended ' char again, but only(!) if the string was actually a number. The info that this cell needs a special treatment when it comes to trailing apostrophe was not stored anywhere and that's why it didn't work for strings such as "'foo". So what I've done is that I introduced a bool flag to ScStringCell to somehow remember that this cell is "special" (ie. its content is indeed a string and this is enforced by ' char at zero position). Otherwise, I kept the logic (striping and prepending ' char, as needed). Attaching patch in a while Created attachment 44130 [details]
Proposed patch
This should fix the bug. Tested it a bit and it works for common cases. Please review, comment, complain etc.
So, the history behind it is that, when you type '10 into a cell, the cell should interpret it as text, even though it's a number. These days, we do the same by setting the cell format to Text, but we still do this for backward compatibility (I guess), and/or because Excel still does it. Regarding the patch, I'm not too keen on adding a special flag with the cell instance itself. Let me look around and see if we can do it another way... I fixed this. There was a simpler way to handle this. http://cgit.freedesktop.org/libreoffice/calc/commit/?id=dfbc969ff099ffae187998cfc5ad88fbb52120f0 BTW the unit test also detected an abuse of this behavior in the datapilot output creation code, which I removed with great pleasure. :-) |