Bug 39969 - Applying formatting doesn't work correctly if cell contains multiple direct formatting sequences
Summary: Applying formatting doesn't work correctly if cell contains multiple direct f...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 83415 108394 155395 158907 158909 (view as bug list)
Depends on: 107965
Blocks: Calc-Cells Cell-Direct-Formatting-Parts
  Show dependency treegraph
 
Reported: 2011-08-09 23:39 UTC by Whistler
Modified: 2024-01-11 16:30 UTC (History)
14 users (show)

See Also:
Crash report or crash signature:


Attachments
test spreadsheet (16.45 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-08-09 23:40 UTC, Whistler
Details
sample ods (12.39 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-06-03 13:53 UTC, Yousuf Philips (jay) (retired)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Whistler 2011-08-09 23:39:37 UTC
Step to reproduce:

1. Open the attached spreadsheet.
2. Select all the cells by clicking the top-left button, and apply any kind of text formating (font, size, text color, etc.).
3. Some texts (specially cell C26, D26 and A28 in this file) are not formatted as expected.

I'm unable to find out the detailed condition on when this happens.
Comment 1 Whistler 2011-08-09 23:40:22 UTC
Created attachment 50087 [details]
test spreadsheet
Comment 2 Rainer Bielefeld Retired 2011-08-10 05:41:36 UTC
I tried to reproduce with "LibreOffice 3.4.2  - WIN7  Home Premium (64bit) German UI [OOO340m1 (Build:203)]" 

1a) In step 2 I selected "font color = red" from picker, and for example in 'C26' half the text remains black. That might be unexpected, but can be explained with a direct formatting for the characters in the cell. 
1b) When I select 'C26' between step 1 and 2, then do menu 'Format -> Clear direct formatting', my step 2 works as expected for 'C26'. 

So there seems to be nothing unexpected.

But:

For me the interesting that I can not see any character format setting "black" or similar when I select one of the characters remaining Black in 'C26'. I would have expected to see that in the menu 'Format -> Cells -> Font Effects', but I only see Style=Default - Color = Automatic.

I see the same behavior with OOo 3.1.1 and LibO3.3.3 Portable

@Whistler:
Can you confirm my observations?
How has your document been created?
Comment 3 Whistler 2011-08-10 18:06:31 UTC
Thanks for reply.

> 1a) In step 2 I selected "font color = red" from picker, and for example in
> 'C26' half the text remains black. That might be unexpected, but can be
> explained with a direct formatting for the characters in the cell.

If "direct formatting" means the format applied to a part of the text manually then I don't think this is correct behavior... as following these steps:

1) create a new spreadsheet document
2) type "This is a test" in any cell
3) select only the word "test" in the cell, and set font color to black
4) select the cell itself, set font color to red

...then all the texts in the cell are red.

also, the formatting works correctly with attached file in M$ Excel 2007 (SP2) and Lotus Symphony 3.


> How has your document been created?

It was originally an M$ Excel template (unable to upload this as it's not allowed by my employer, sorry). I just typed in all the texts with libreoffice and saved it as opendocument and did not do something special (eg. editing the xmls manually, etc).
Comment 4 Jeffrey 2011-08-13 06:49:12 UTC
Confirmed for LibreOffice 3.4  340m1(Build:103) on OpenSuse Linux. It looks like the formatting problem has to do with bullet points, for in cells C26 and D26 the formatting stops at the bullets.

Also, I followed Rainer's point on clear direct formatting, which is a workaround to the problem.

Thanks for the document and the steps.
Comment 5 Rainer Bielefeld Retired 2011-09-02 01:26:13 UTC
CONFIRMED due to Comment 4

To me this cell internal formatting seems to be totally broken. I have been used to see that  cell internal  formatting with priority to complete cell formatting. That means when I have a Cell contents "One red word" and modify word "red" to red character color, this color should remain red when I selec tell with cell cursor and change character color to blue - only characters of words "One" and "word" should become red. So it works in OOo 3.1.1. In LibO 3.4 also word "red" becomes blue. That is something different to the observations here, but might be related. 

@David
I believe this priority issue needs some more elaborated info in Help and Documentation

@kohei
Please feel free to reassign (or reset Assignee to default) if it’s not your area or if provided information is not sufficient. Please set Status to ASSIGNED if you accept this Bug.
Comment 6 David Nelson 2011-09-02 01:34:36 UTC
Rainer, OK, I've bookmarked this bug in my mail for my to-do list, and forwarded info to the docs ML in case someone wants to step in and act.
Comment 7 Whistler 2011-09-03 06:26:50 UTC
just a note:

> That means when I have a Cell contents "One red word" and modify
> word "red" to red character color, this color should remain red when I selec
> tell with cell cursor and change character color to blue - only characters of
> words "One" and "word" should become red. So it works in OOo 3.1.1. In LibO 3.4
> also word "red" becomes blue. That is something different to the observations
> here, but might be related. 

I tried the following ones:

OOo 3.1.0
Gnumeric 1.8.3
M$ Office 2003
M$ Office 2007 SP2
Lotus Symphony 3

...and none except Gnumeric has the mentioned behavior (ie. in all of the above except Gnumeric the word "red" become blue as well).
(I would like to try KSpread and Google Docs as well however I didn't figure out how to apply formats to texts)
Comment 8 Björn Michaelsen 2011-12-23 13:27:03 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2015-02-19 15:50:31 UTC Comment hidden (obsolete)
Comment 10 Whistler 2015-02-22 07:12:55 UTC
This bug still exists (LiberOffice 4.3.5 under GNU/Linux).
Comment 11 Whistler 2015-02-25 13:01:27 UTC
4.4.0.3 under Windows also has the same bug.
Comment 12 tommy27 2016-04-16 07:25:52 UTC Comment hidden (obsolete)
Comment 13 QA Administrators 2017-05-22 13:27:50 UTC Comment hidden (obsolete)
Comment 14 Yousuf Philips (jay) (retired) 2017-06-03 13:04:36 UTC
Confirmed in master

Version: 5.5.0.0.alpha0+
Build ID: b08217989558addbcaded122a4e7211ae24bbcff
CPU threads: 2; OS: Linux 4.4; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-05-31_06:36:03
Locale: en-US (en_US.UTF-8); Calc: group
Comment 15 Yousuf Philips (jay) (retired) 2017-06-03 13:53:40 UTC
Created attachment 133824 [details]
sample ods

So i created this sample spreadsheet in 5.5 master.

If you select C2 and apply italics and then unapply italics, the text previously having italics retain italics. So if we investigate the xml, we see the C2 originally is like so.

 <style:style style:name="T3" style:family="text">
   <style:text-properties fo:font-style="italic" ... />
 </style:style>
 <style:style style:name="T4" style:family="text">
   <style:text-properties fo:font-style="italic" ... />
 </style:style>

 <table:table-cell ...>
   <text:p>
     <text:span text:style-name="T3">Italic Text</text:span>
   </text:p>
   <text:p>Non-Italic Text</text:p>
   <text:p>
     <text:span text:style-name="T4">Italic Text</text:span>
   </text:p>
 </table:table-cell>

And after apply the italics, it has applied it at the cell level and not at the individual paragraph levels, as the xml looks like this.

 <style:style style:name="ce2" style:family="table-cell" ... >
   <style:text-properties fo:font-style="italic" ... />
 </style:style>

 <table:table-cell table:style-name="ce2" ... >
   <text:p>
     <text:span text:style-name="T3">Italic Text</text:span>
   </text:p>
   <text:p>Non-Italic Text</text:p>
   <text:p>
     <text:span text:style-name="T4">Italic Text</text:span>
   </text:p>
 </table:table-cell>

And when unapplying the italics, it also sets it at the cell level, which the paragraph level attributes will ignore.

 <style:style style:name="ce3" style:family="table-cell" ... >
   <style:text-properties fo:font-style="normal" ... />
 </style:style>

 <table:table-cell table:style-name="ce3" ... >
   <text:p>
     <text:span text:style-name="T3">Italic Text</text:span>
   </text:p>
   <text:p>Non-Italic Text</text:p>
   <text:p>
     <text:span text:style-name="T4">Italic Text</text:span>
   </text:p>
 </table:table-cell>

This problem can also be seen with D2 when applying & unapplying underline and should also be seen in B2 when applying & unapplying bold, but it is broken.
Comment 16 Yousuf Philips (jay) (retired) 2017-06-20 21:46:35 UTC
*** Bug 108394 has been marked as a duplicate of this bug. ***
Comment 17 Thomas Lendo 2018-03-13 23:18:06 UTC
Is this really a bug?

I can't see any mistake in Jay's xml code in comment 15 - the direct formatted cell content (aka span styles) stay in its condition, no matter what attributes the cell as a whole (aka cell style) gets or loses. The first test file works well after doing Ctrl+M on all cells.

The whole situation is the cause why I wish character (span) styles also in Calc (Bug 108220 - Add Character styles in Calc cells).

Version: 6.1.0.0.alpha0+
Build ID: cab04bc39b5164ea74216cd849c3af5f5b298f79
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; 
Locale: de-DE (de_DE.UTF-8); Calc: group

The only bug I see here is the different behaviors similar as described in comment 3.

1. Create a spreadsheet with some text in a cell.
2. Copy the cell content to other cells so that several rows and columns are filled.
3. Select a single character or word in a random cell and assign color red.
4a. Select all cells of the sheet and assign font color blue. -> The red text is still red.
4b. Select a random range of cells including the cell with red text and assign font color green. -> The red text is now green.
4c. Undo the last step and select the column with the cell with red text and assign font color yellow. -> The red text is still red.
4d. Select the row with the cell with red text and assign font color purple. -> The red text is now purple.
4e. Undo the last step and select only the cell with red text and assign font color lime. -> The red text is now lime.
Comment 18 QA Administrators 2019-03-14 03:52:09 UTC Comment hidden (obsolete)
Comment 19 naitsirch 2020-12-14 13:35:44 UTC
I can confirm that this bug still exists in LibreOffice 6.4.7.2, although a similiar issue (inline formatting of font size) has been fixed (see https://bugs.documentfoundation.org/show_bug.cgi?id=90781#c12).
Comment 20 Whistler 2021-11-01 11:50:24 UTC
This bug still exists:

Version: 7.2.2.2
Build ID: 20(Build:2)
CPU threads: 4; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 21 Stéphane Guillou (stragu) 2023-05-22 22:31:50 UTC
*** Bug 155395 has been marked as a duplicate of this bug. ***
Comment 22 Stéphane Guillou (stragu) 2023-11-07 22:04:52 UTC
*** Bug 83415 has been marked as a duplicate of this bug. ***
Comment 23 Stéphane Guillou (stragu) 2024-01-11 16:17:46 UTC
*** Bug 158907 has been marked as a duplicate of this bug. ***
Comment 24 Stéphane Guillou (stragu) 2024-01-11 16:22:09 UTC
*** Bug 158909 has been marked as a duplicate of this bug. ***
Comment 25 Stéphane Guillou (stragu) 2024-01-11 16:30:48 UTC
Something that might be useful in resolving this issue: the result very much depends on what cell range is selected, as noted in bug bug 90781 comment 13 and bug 158907 comment 3.

Using the bug 158907 sample file:
1. Open attachment 191615 [details]
2. Try changing the font size on the following ranges:
- column A: works on some cells
- cell A3: works
- cell A4: works
- cell A5: works
- row 3: works, but everything is bold
- A3:A4: works, but everything is bold
- A3:A5: does not work

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3cb1ed4339fc9aec414c0f112a69705a7a4d9cc6
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded