Description: If I try to remove cell style formatting on a Calc sheet cell range by a macro, nothing happens: oRange.clearContents(com.sun.star.sheet.CellFlags.STYLES) But if I combine STYLES with HARDATTR, not only all hard formatting is set to default, but formatting with cell styles is removed as well. This way you can remove cell style formatting, but with the drawback of getting default formats in the rest of the cells. 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). Steps to Reproduce: 1. Format a sheet cell with some cell style. 2. Take a cell range oRange containing that cell. 3. oRange.clearContents(com.sun.star.sheet.CellFlags.STYLES) 4. Nothing happens 5. oRange.clearContents(com.sun.star.sheet.CellFlags.HARDATTR Or com.sun.star.sheet.CellFlags.STYLES) Actual Results: With (com.sun.star.sheet.CellFlags.STYLES) alone nothing happens. With (com.sun.star.sheet.CellFlags.HARDATTR Or com.sun.star.sheet.CellFlags.STYLES) all cells in the range are reset to default formats incl. the cell with cell style. Expected Results: With (com.sun.star.sheet.CellFlags.STYLES) alone all cells formatted by cell styles should be reset to default formats. 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
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
I can confirm it for LibO 6.0.0.2 32-Bit, Windows 10
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.)
Created attachment 140291 [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, B3 being formatted with a cell style, as well as two cells (B4 and C4) with text portion formatting. You can try the effect on B3 (in fact no effect at all) by calling the macro Sub ClearContentsByCellFlagsSTYLES If you call the macro Sub ClearContentsByCellFlagsHARDATTROrSTYLES then not only all cell formatting is set to default, but B3 loses the cell style, too. The file comes with an additional macro to serve as an example for bug 116127 as well: Sub ClearContentsByCellFlagsEDITATTR
.
https://opengrok.libreoffice.org/xref/core/sc/source/core/data/column3.cxx?r=fb9a5d89#1016 What would happen if nDelFlag has STYLES only when (ATTRIB == (HARDATTR | STYLES))? https://opengrok.libreoffice.org/xref/core/sc/inc/global.hxx?r=a2601800#175 I first thought it could be ok if I rewrite (nDelFlag & InsertDeleteFlags::ATTRIB) != InsertDeleteFlags::NONE instead of (nDelFlag & InsertDeleteFlags::ATTRIB) == InsertDeleteFlags::ATTRIB , but in that case it seems, at least to me , that we would not at all need else-if section.
Dear Volker Lenhardt, To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
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
In addition: With LO 3.3.0 on Linux openSUSE Tumbleweed (Leap 15.2) the macro removes all hard attributes, but leaves the cell styles untouched. Weird. It should have done the other way round. But this is history. Greetings, Volker
The relevant code for the clearContents method is in column3.cxx: // Delete attributes just now if ((nDelFlag & InsertDeleteFlags::ATTRIB) == InsertDeleteFlags::ATTRIB) pAttrArray->DeleteArea( nStartRow, nEndRow ); else if ((nDelFlag & InsertDeleteFlags::HARDATTR) == InsertDeleteFlags::HARDATTR) pAttrArray->DeleteHardAttr( nStartRow, nEndRow ); So the InsertDeleteFlags::ATTRIB checks for HARDATTR | STYLES. Hence, calling clearContents using just with the STYLES attribute never deletes anything from the selected cells. Changing it to (nDelFlag & InsertDeleteFlags::ATTRIB) != InsertDeleteFlags::NONE makes the next statement obsolete (like himajin100000 pointed out). So I would suggest to change it to: // Delete attributes just now if ((nDelFlag & InsertDeleteFlags::STYLES) == InsertDeleteFlags::STYLES) pAttrArray->DeleteArea( nStartRow, nEndRow ); if ((nDelFlag & InsertDeleteFlags::HARDATTR) == InsertDeleteFlags::HARDATTR) pAttrArray->DeleteHardAttr( nStartRow, nEndRow ); But I am not sure if the actual results are expected. I will attach them to the bug report.
Created attachment 186600 [details] Result of the change in comment 10
(In reply to Gerhard Weydt from comment #2) > I can confirm it for LibO 6.0.0.2 32-Bit, Windows 10 Prior to LO 7.4 there was no ScriptForge so all versions before can't work
(In reply to DZ from comment #12) > (In reply to Gerhard Weydt from comment #2) > > I can confirm it for LibO 6.0.0.2 32-Bit, Windows 10 > > Prior to LO 7.4 there was no ScriptForge so all versions before can't work Sorry wrong thread, I can't delete my previous comment