Bug 116127 - Cell Range method ClearContents does not work with com.sun.star.sheet.CellFlags.EDITATTR
Summary: Cell Range method ClearContents does not work with com.sun.star.sheet.CellFla...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2018-03-01 17:57 UTC by Volker Lenhardt
Modified: 2021-09-25 13:36 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Macros to display bugs using Calc cell range method clearContents with some CellFlags (13.26 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-03-02 12:55 UTC, Volker Lenhardt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Lenhardt 2018-03-01 17:57:14 UTC
Description:
If I try to clear formatting within parts of the cell contents on a cell range by a macro, nothing happens:

oRange.clearContents(com.sun.star.sheet.CellFlags.EDITATTR)

This behavior is proved for Windows 7, LO 5.3.7., Windows 10, LO 6.0.0.2 (32 bit) and for Linux openSUSE LEAP 42.2 with LO 5.3.0 and LO 6.0.1.1 (both generic versions).

Doing so in AOO (any version) operates as desired, it clears the formatting of text portions and gives the whole text the actual cell format.


Steps to Reproduce:
1. Take a sheet cell containing the text "blue and yellow".
2. Select the words "blue" and "yellow" and give them the CharColors blue and yellow resp.
3. Take a cell range oRange containing that cell.
4. oRange.clearContents(com.sun.star.sheet.CellFlags.EDITATTR)

Actual Results:  
All formats of text portions in a Calc sheet cell remain untouched.

Expected Results:
The formatting of text portions should be cleared and the whole text should be given the color of the actual cell format.


Reproducible: Always


User Profile Reset: No



Additional Info:


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Hans-Werner 2018-03-01 19:11:17 UTC
Confirmed for:
+ LibO 5.3.7.2 (x64) @ Windows 7 Home Premium 64-bit
+ LibO 6.0.2.1 (x64) @ Windows 7 Home Premium 64-bit
Greetings Hans-Werner
Comment 2 Gerhard Weydt 2018-03-01 20:21:06 UTC
I can confirm it for LibO 6.0.0.2 32-Bit, Windows 10
Comment 3 Xisco Faulí 2018-03-02 08:59:55 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 4 Volker Lenhardt 2018-03-02 12:55:41 UTC
Created attachment 140289 [details]
Macros to display bugs using Calc cell range method clearContents with some CellFlags

This attachment shows a set of formatted cells, numbers, date/time, strings, as well as two cells (B4 and C4) with text portion formatting.

You can try the effect on B4:C4 (in fact no effect) by calling the macro
Sub ClearContentsByCellFlagsEDITATTR

The file comes with two additional macros to serve as an example for bug 116129 as well:
Sub ClearContentsByCellFlagsHARDATTROrSTYLES
Sub ClearContentsByCellFlagsSTYLES
Comment 5 Oliver Brinzing 2018-03-02 16:33:58 UTC Comment hidden (obsolete)
Comment 6 himajin100000 2019-09-20 22:36:44 UTC
Just a guess:

https://opengrok.libreoffice.org/xref/core/sc/source/ui/unoobj/cellsuno.cxx?r=316b07d0#1819
https://opengrok.libreoffice.org/xref/core/sc/inc/global.hxx?r=a2601800#177
https://opengrok.libreoffice.org/xref/core/sc/inc/global.hxx?r=a2601800#169

InsertDeleteFlags::ALL does not contain flags for EDITATTR
Shouldn't this be 

( static_cast<InsertDeleteFlags>(nContentFlags) & InsertDeleteFlags::EDITATTR )

instead of 

( nDelFlags & InsertDeleteFlags::EDITATTR )  

?
Comment 7 QA Administrators 2021-09-21 04:52:29 UTC Comment hidden (obsolete)
Comment 8 Volker Lenhardt 2021-09-25 12:16:21 UTC
As with LO 7.1.6.2 and 7.2.1.2 both on macOS Big Sur (11.6) and with LO 7.1.6.2 on openSUSE Leap Tumbleweed there is no different behaviour. The bug persists as specified before.
With regards, Volker
Comment 9 Volker Lenhardt 2021-09-25 13:36:13 UTC
In addition: With LO 3.3.0 on Linux openSUSE Tumbleweed (Leap 15.2) the macro works as desired, it clears the formatting of text portions and gives the whole text the actual cell format.
Greetings, Volker