but I can't find the strings to put for how to set the Appearance/Section Boundaries to on or off...
or even to access the Appearance settings. Anyone know this?
Sub ChangeMacroSecurity
Dim sNodePath As String
Dim oCP, oCUA
' sNodePath = "/org.openoffice.Office.Common/Security/Scripting"
sNodePath = "/org.openoffice.Office.Common.Appearance" '???????????????' this doesn't work.
Dim aProps(0) As New com.sun.star.beans.PropertyValue
oCP = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" )
aProps(0).Name = "nodepath"
aProps(0).Value = sNodePath
oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps )
' oCUA.MacroSecurityLevel = 0
oCUA.SectionBoundaries '???????????????
oCUA.commitChanges()
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
I virtually never use sections and I rarely tamper with the hidden parts of the configuration (in LibreOffice accessible as 'Expert Configuration'). It was, however fun to first stabb in the dark a bit and finally find out by "Thinking and Trial" how to access and to change the respective configuration property. Your slightly reworked code:
Sub printAndToggleWriterSectionBoundaryVisibility()
Dim sNodePath As String
Dim oCP, oCUA
sNodePath = "/org.openoffice.Office.UI/ColorScheme/ColorSchemes"
Dim aProps(0) As New com.sun.star.beans.PropertyValue
oCP = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" )
aProps(0).Name = "nodepath"
aProps(0).Value = sNodePath
oCUA = oCP.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aProps )
Print oCUA.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible
oCUA.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible = _
NOT oCUA.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible
Print oCUA.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible
oCUA.commitChanges()
End Sub
Option Explicit
Sub setWriterSectionBoundaryVisibility(Optional pNext As String)
If IsMissing(pNext) Then pNext = "toggle"
Dim nodePath As String, newState As Boolean
Dim confProv As Object, updateAccess As Object
nodePath = "/org.openoffice.Office.UI/ColorScheme/ColorSchemes"
Dim props(0 To 0) As New com.sun.star.beans.PropertyValue
confProv = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" )
props(0).Name = "nodepath"
props(0).Value = nodePath
updateAccess = confProv.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", props )
Select Case pNext
Case "on"
newState = True
Case "off"
newState = False
Case "toggle"
newState = NOT updateAccess.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible
Case Else
Exit Sub
End Select
updateAccess.GetByName("OpenOffice").WriterSectionBoundaries.IsVisible = newState
updateAccess.commitChanges()
End Sub
Of course this only is "final" concerning the ColorScheme "OpenOffice". If different ColorScheme are to handle ("LibreOffice" e.g.) you may introduce a second parameter pColorSchemeName and use updateAccess.HasByName(pColorSchemeName) or similar. The updateAccess object also has an array-porperty ElementNames.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Now I know its WriterSectionBoundaries I see someone's asked for it before, in a French thread. I should have looked at the file the settings are all in - but I spent ages on it without thinking of that.
I haven't used sections before either - but I'm writing a screenwriting extension - and the best way to do it looks to be to put each scene in a separate section. Then scenes can be individually protected, hidden, color coded with the background color etc.
Great thanks!
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
I just tried with LibO. My findings:
-0- The "org.OpenOffice" part in the node path is unchanged.
-1- The (default?) ColorScheme is named "LibreOffice" there (as should be expected).
-2- The property .WriterSectionBoundaries.IsVisible does still exist.
-3- This property can be edited by the Sub if the name of the ColorScheme is adapted.
-4- There is no longer offered a way to edit it via the Options dialogues. -5- The property is no longer evaluated. SectionBoundaries are always visible. -6- Relying on this property is not compliant with interoperability between AOO and LibO.
I did not find an explicit statement about this in the LibreOffice release notes.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Its there in the Options Dialogue/Application colors/Text document
Playing - the problem seems to be visibility depends on text boundaries being visible or not, not on the setting for the section boundary
Setting the color to white has the effect of hiding the border so its possible to have text boundaries visible but secion boundaries looking like they aren't because they're white. But it doesn't look possible to have text boundaries not visible but section boundaries visible.
Sub setWriterSectionBoundaryVisibility()
Dim nodePath As String, newState As Boolean
Dim confProv As Object, updateAccess As Object
' nodePath = "/org.openoffice.Office.UI/ColorScheme/ColorSchemes"
nodePath = "/org.openoffice.Office.UI/ColorScheme/ColorSchemes/org.openoffice.Office.UI:ColorScheme['LibreOffice']" '/WriterSectionBoundaries"
Dim props(0 To 0) As New com.sun.star.beans.PropertyValue
confProv = CreateUnoService("com.sun.star.configuration.ConfigurationProvider" )
props(0).Name = "nodepath"
props(0).Value = nodePath
updateAccess = confProv.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", props )
updateAccess.WriterSectionBoundaries.isVisible = false
updateAccess.WriterSectionBoundaries.color = rgb(255,255,255)
updateAccess.commitChanges()
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
I only have LibreOffice 5.3 - if they've ditched the option to set the section boundary visibility in the latest version in the Options dialog... it would make sense in terms of the feature not appearing to work anymore... but it would be better to keep/fix the feature.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)