Hi Fernand,
Thank you for your response, it may help indeed.
It seems that you create your own xcs file from scratch and store it in a
custom location. I think that in my case, I will need to find a way to make
it cross platform and environment independent.
Cheers
2012/1/24 Fernand Vanrie <sos@pmgroup.be>
Martin ,
i use folowed BASIC code to make a "path" consitent , maybe it helps ?
public sElementnaam , sfotopath as string
public oParameter as object
sub addFotoPath()
sRegisterPath = "/org.openoffice.OpmaakMacro.FotoPath/Parameters/"
CreateRegistrySchemaPathIfNotPresent(sRegisterPath)
aSettings = GetConfigSettings(sRegisterPath)
sElementNaam = "FOTO"
sParaNaam = "FotoPath"
sParameter = "c:\test"
call addParameter(aSettings, sParaNaam, sParaMeter)
end sub
sub getFotoPath
sRegisterPath = "/org.openoffice.OpmaakMacro.FotoPath/Parameters/"
aSettings = GetConfigSettings(sRegisterPath)
asElNames = aSettings.ElementNames
if aSettings.hasByName("FOTO") then
oParameter = aSettings.getByName("FOTO")
sFOTOpath = oParameter.getByName("ParameterString")
else
sFOTOpath = ""
endif
end sub
function GetConfigSettings(sRegisterPath as String) as Object 'Taken from
DannyB
Dim args(1) As new com.sun.star.beans.PropertyValue
aConfProv =
createUnoService("com.sun.star.configuration.ConfigurationProvider")
args(1).Name = "nodepath"
args(1).Value = sRegisterPath
args(0).Name = "EnableAsync"
args(0).Value = false
GetConfigSettings =
aConfProv.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",
args())
end function
sub CreateRegistrySchemaPathIfNotPresent(sRegisterPath as String)
oPathSettings = CreateUnoService( "com.sun.star.util.PathSettings" )
xray oPathSettings
sPathConfig = oPathSettings.Work 'Config
asPath1 = split(sRegisterPath, "/")
sFullDotPath = asPath1(1)
asPath2 = Split(sFullDotPath,".")
sFolder = join(asPath2,"/")
sRegistrySchemaPath = "file:///H:/" & sFolder & ".xcs"
sFileName = asPath2(UBound(asPath2))
sPackage = left(sFullDotPath, len(sFullDotPath)-len(sFileName)-1)
oSFA = createUNOService ("com.sun.star.ucb.SimpleFileAccess")
if not oSFA.exists(sRegistrySchemaPath) then 'See the chapter 15 of the
dev guide for some explanation
print sRegistrySchemaPath
oOutStream = oSFA.openFileWrite(sRegistrySchemaPath)
oOutText = createUNOService ("com.sun.star.io.TextOutputStream")
oOutText.setOutputStream(oOutStream)
oOutText.WriteString("<?xml version='1.0' encoding='UTF-8'?>" & Chr(10))
oOutText.WriteString("<oor:component-schema oor:name=""" & sFileName &
""" oor:package=""" & sPackage & """ " )
oOutText.WriteString("xml:lang=""en-US"" xmlns:oor="
"http://openoffice.org/2001/registry"<http://openoffice.org/2001/registry>"
" )
oOutText.WriteString("xmlns:xs=""http://www.w3.org/2001/XMLSchema"<http://www.w3.org/2001/XMLSchema>"
" )
oOutText.WriteString("xmlns:xsi="
"http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance>">"
& Chr(10))
oOutText.WriteString("<templates>" & Chr(10))
oOutText.WriteString(" <group oor:name=""Parameter"">" & Chr(10))
oOutText.WriteString(" <prop oor:name=""ParameterName""
oor:type=""xs:string""/>" & Chr(10))
oOutText.WriteString(" <prop oor:name=""ParameterString""
oor:type=""xs:string""/>" & Chr(10))
oOutText.WriteString(" </group>" & Chr(10))
oOutText.WriteString("</templates>" & Chr(10))
oOutText.WriteString("<component>" & Chr(10))
oOutText.WriteString(" <set oor:name=""Parameters""
oor:node-type=""Parameter""/>" & Chr(10))
oOutText.WriteString("</component>" & Chr(10))
oOutText.WriteString("</oor:component-schema>" & Chr(10))
oOutText.closeOutput()
oOutStream.closeOutput
endif
end sub
sub addParameter(aSettings as Object, ParameterName as String,
ParameterString as String)
Dim arParameters1(0) As new com.sun.star.beans.PropertyValue
arParameters1(0).Name = ParameterName
arParameters1(0).Value = ParameterString
call setParameters(aSettings, arParameters1(0))
end sub
function getParameterCount(aSettings as Object) as long
getParameterCount = UBound(aSettings.ElementNames)+1
end function
sub setParameters(aSettings as Object, aNewValue as Object)
if aSettings.hasbyName(sElementnaam) then
'print aNewvalue.name
oParameter = aSettings.createInstance()
oParameter.ParameterName = aNewValue.Name
oParameter.ParameterString = aNewValue.Value
aSettings.ReplaceByName(sElementNaam , oParameter)
aSettings.commitChanges()
else
oParameter = aSettings.createInstance()
oParameter.ParameterName = aNewValue.Name
oParameter.ParameterString = aNewValue.Value
aSettings.insertByName(sElementNaam , oParameter)
aSettings.commitChanges()
endif
end sub
Hi everybody,
I'm hacking the cross-platform filepicker (in fpicker/source/office). I
added a "Places" (bookmarks) list on the left and I would like to save the
entries that the user bookmarked .
Cedric Bosdonnat told me to look at xcu and xcs files, but I'm a bit lost.
I'm looking for a code sample where user's persistent configuration is
manipulated (read and written) and/or anything that can be usefull, like
search keywords, links to old threads in the mailing list, which would help
me to identify some good practices (naming conventions, for instance).
Cheers,
Martin Richard
_______________________________________________
LibreOffice mailing
listLibreOffice@lists.freedesktop.orghttp://lists.freedesktop.org/mailman/listinfo/libreoffice
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice
--
Martin <http://www.martiusweb.net> Richard
www.martiusweb.net <http://www.martiuweb.net>
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.