Hi Fernand,
Fernand Vanrie escribió:
I can handle without any problem all CustomStyles in a writterDoc using
Basic and the API
BUT : i find no Method to "remove" a style
I can check if the style in no longer in use ( whats neceraly to been
removed) oStyle.IsInUse = false
but even then there is no method to remove this unused style, is this a
forgotten API thing or is there a other way to remove styles ?
Thanks for any hint
the css.style.StyleFamily is a container of styles, that means:
XNameContainer:removeByName( [in] string Name )
as simple as:
...
If oStyle.IsUserDefined AND NOT oStyle.IsInUse Then
oFamily.removeByName( sStyleName )
End If
or in a dummy/annoying example:
Sub [Remove NOT used User-defined styles]
Dim oDoc as Object, oStyleFamilies as Object, oFamily as Object
Dim sStyleFamilyNames$(), sFamilyName$
oDoc = ThisComponent
oStyleFamilies = oDoc.getStyleFamilies()
sStyleFamilyNames = oStyleFamilies.getElementNames()
Dim sMessage$, iMessage%, nCount&, sDeletedMessage$
Dim CR$ : CR = chr(13) & chr(13)
For Each sFamilyName In sStyleFamilyNames
oFamily = oStyleFamilies.getByName(sFamilyName)
Dim sStyles$(), sStyle$, oStyle as Object
sStyles = oFamily.getElementNames()
For Each sStyle In sStyles
oStyle = oFamily.getByName(sStyle)
If oStyle.IsUserDefined AND NOT oStyle.IsInUse Then
sMessage = "The user-defined style " & CR &_
"""" & sStyle & """" & CR &_
"from the style family """ & _
sFamilyName & """" & CR &_
"is not being used in the current document.
"&_
"Do you want to remove it?" & CR
iMessage = MsgBox (sMessage, 1 + 256,_
"Remove NOT used User-defined styles")
If (iMessage = 1) then
oFamily.removeByName( sStyle )
nCount = nCount + 1
sDeletedMessage = sDeletedMessage & """" & sStyle &
""""_
& chr(9) & sFamilyName & chr(13)
'annoying confirmation message box!
MsgBox """" & sStyle & """ deleted!",
48, _
"annoying confirmation message
box!"
End If
End If
Next
Next
MsgBox nCount & " styles have been deleted:" & chr(13) & chr(13) &_
sDeletedMessage , 64, "Deleted styles"
End Sub
Checking this I've seen a dead link in
http://api.openoffice.org/docs/common/ref/com/sun/star/style/XAutoStylesSupplier.html
in the Methods' Details there says "see AutoStyle", and links to
http://api.openoffice.org/docs/common/ref/com/sun/star/style/XAutoStylesSupplier.html#AutoStyles
Should it link to some (undocumented/nonexistent?) service named
css.style.AutoStyles or to
http://api.openoffice.org/docs/common/ref/com/sun/star/style/XAutoStyle.html?
Regards
Ariel.
--
Ariel Constenla-Haile
La Plata, Argentina
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]