Issue 125195 - Can't delete junk styles
Summary: Can't delete junk styles
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: Writer
Classification: Application
Component: editing (show other issues)
Version: 4.1.0
Hardware: PC Windows 7
: P3 Major (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: needmoreinfo
Depends on:
Blocks:
 
Reported: 2014-07-03 13:34 UTC by Darius Daniel Grigoras
Modified: 2020-01-08 19:40 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Demo file with junk styles (260.87 KB, application/vnd.oasis.opendocument.text)
2014-07-04 08:15 UTC, Darius Daniel Grigoras
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Darius Daniel Grigoras 2014-07-03 13:34:08 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.
Comment 1 oooforum (fr) 2014-07-04 07:37:12 UTC
Could you attach a sample file to reproduce?
Comment 2 Darius Daniel Grigoras 2014-07-04 08:15:30 UTC
Created attachment 83637 [details]
Demo file with junk styles

Demo file with junk styles
Comment 3 Darius Daniel Grigoras 2014-07-04 08:16:30 UTC
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.
Comment 4 Darius Daniel Grigoras 2014-07-04 08:20:15 UTC
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
Comment 5 oooforum (fr) 2014-07-04 13:19:05 UTC
(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
Comment 6 Darius Daniel Grigoras 2014-07-04 13:27:33 UTC
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.
Comment 7 oooforum (fr) 2014-07-04 14:38:26 UTC
(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.
Comment 8 Darius Daniel Grigoras 2014-07-04 14:44:57 UTC
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
Comment 9 Ariel Constenla-Haile 2014-07-04 16:03:42 UTC
(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
Comment 10 Darius Daniel Grigoras 2014-07-04 16:12:31 UTC
(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#
Comment 11 Ariel Constenla-Haile 2014-07-04 16:27:06 UTC
(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.
Comment 12 oooforum (fr) 2020-01-08 19:27:01 UTC
According with previous comment

Solution is with a macro

Use our Community forum or mailing list if you want help to coding this.