Apache OpenOffice (AOO) Bugzilla – Issue 125195
Can't delete junk styles
Last modified: 2020-01-08 19:40:41 UTC
I am copying into an ODT template the content of some SXW files, which have their content copied from DOCX files. The problem is that junk styles have been copied from the DOCX files and most of these junk styles are locked and I cannot delete them from the ODT file whatever I do.
Could you attach a sample file to reproduce?
Created attachment 83637 [details] Demo file with junk styles Demo file with junk styles
Ok, I have attached a demo file. Even though I've deleted most of the text, those junk styles are still there and there are lots of them.
The junk styles are usually just Character and List styles with names of this pattern: WW8Num##z# (where # stands for different digits, numbers). Others, fewer in number, have names like this: 79761500416052791121z0
(In reply to Darius Daniel Grigoras from comment #0) > and most of these junk styles are locked and > I cannot delete them from the ODT file whatever I do. I use the stylist and have no problem to remove WW8Num##z# styles. Right click and choose Delete menu
Of course you can delete them now, because the text to which these styles were applied is deleted, but as long as the text is there (which is confidential), you cannot delete them.
(In reply to Darius Daniel Grigoras from comment #6) > but as long as the text is there (which is > confidential), you cannot delete them. Well, if the style is in use, you couldn't delete it. So you must reattach text to another style with Search and replace menu before. Bugzilla is make to report bug not to help. I also would suggest that in your case using the documentation or the forum (https://forum.openoffice.org/en/forum/) would have been preferable.
There are too many junk styles to Search & Replace for. That would be too time-consuming. Besides that, I can't just search and replace them, as some formatting would get lost and I would find it harder to reproduce these styles. Though I admit that I create PDFs for reference. I reported this as a bug, because I felt that one should be allowed to select multiple styles in order to delete them and that one should be allowed to delete them all even if they are in use. That would make things so much easier. Right now I am manually removing them from styles.xml and content.xml So my requests are these: - allow selection of multiple styles - allow deletion of styles in use
(In reply to Darius Daniel Grigoras from comment #6) > Of course you can delete them now, because the text to which these styles > were applied is deleted, It is possible to delete custom styles even if they are used in the document (you will lose the formatting, though). > but as long as the text is there (which is > confidential), you cannot delete them. Can you replace all text with X? (In reply to Darius Daniel Grigoras from comment #8) > So my requests are these: > - allow selection of multiple styles > - allow deletion of styles in use AFAIK this is possible. Just try with a new Writer document, create a paragraph style, apply it to a paragraph, go to the Stylist and erase. You can delete all custom styles that are not being used with a simple macro: REM ***** BASIC ***** Option Explicit Sub Main Dim oStyles Dim oFamily Dim oStyle oStyles = ThisComponent.getStyleFamilies() Dim sStyleFamily$, aElementNames$() Dim sStyle$, aStyles$() aElementNames = oStyles.getElementNames() For Each sStyleFamily In aElementNames oFamily = oStyles.getByName(sStyleFamily) aStyles = oFamily.getElementNames() For Each sStyle In aStyles oStyle = oFamily.getByName(sStyle) If oStyle.isUserDefined() AND NOT oStyle.isInUse() Then oFamily.removeByName(sStyle) End If Next Next End Sub
(In reply to Ariel Constenla-Haile from comment #9) > It is possible to delete custom styles even if they are used in the document > (you will lose the formatting, though). If it's possible to delete styles in use, why can't I delete most of them? Can you make a macro that would delete styles with names like the ones enumerated bellow? # should be replaced with regex [0-9] WW8Num##z### WW8Num##z## WW8Num##z# WW8Num#z### WW8Num#z## WW8Num#z# ####################z#
(In reply to Darius Daniel Grigoras from comment #10) > (In reply to Ariel Constenla-Haile from comment #9) > > > It is possible to delete custom styles even if they are used in the document > > (you will lose the formatting, though). > > If it's possible to delete styles in use, why can't I delete most of them? That might be the bug, but we need access to the file in order to reproduce it. > Can you make a macro that would delete styles with names like the ones > enumerated bellow? # should be replaced with regex [0-9] > WW8Num##z### > WW8Num##z## > WW8Num##z# > WW8Num#z### > WW8Num#z## > WW8Num#z# > ####################z# OpenOffice Basic does not support regex, but that macro can be rewritten in Python, which does support them.
According with previous comment Solution is with a macro Use our Community forum or mailing list if you want help to coding this.