Code: Select all
Sub MyTime_enGB_HMMap()
REM assign H:MMa/p in US locale to this document's cell style "MyTime"
MakeUDNF ThisComponent, sStyle:="BlueTime", sLang:="en", sCountry:="GB", sCode:="H:MMa/p"
End Sub
Sub MakeUDNF(oDoc, sStyle, sLang, sCountry, sCode)
oLoc = createUnoStruct("com.sun.star.lang.Locale")
oLoc.Language = sLang
oLoc.Country = sCountry
oStyles = oDoc.StyleFamilies.getByName("CellStyles")
oStyle = oStyles.getByName(sStyle)
REM queryKey ( [in] string aFormat, [in] .lang.Locale nLocale, [in] boolean bScan ) long .util.XNumberFormats
REM addNew ( [in] string aFormat, [in] .lang.Locale nLocale ) long .util.XNumberFormats
oNFs = oDoc.getNumberFormats()
intNFKey = oNFs.queryKey(sCode, oLoc, True)
REM intNFKey is always -1 for existing crude number formats
on error goto exit_err
' print intNFKey
if intNFKey = -1 then intNFKey = oNFs.addNew(sCode, oLoc)
oStyle.NumberFormat = intNFKey
exit_err:
End Sub
Code: Select all
Sub BlueTime()
REM assign H:MMa/p in US locale to this document's cell style "MyTime"
MakeUDNF ThisComponent, sStyle:="BlueTime", sLang:="en", sCountry:="GB", sCode:="H:MMa/p"
End Sub
Sub YellowTime()
REM assign H:MMa/p in US locale to this document's cell style "MyTime"
MakeUDNF ThisComponent, sStyle:="YellowTime", sLang:="en", sCountry:="GB", sCode:="H:MMa/p"
End Sub
So, how can I modify both styles? And is there a way to modify all user-defined styles as I always prefer H:MMa/p for the time?