lib: Write.Ods.styleNames: common generation of ODS style names for both formatCell and cellConfig
This commit is contained in:
parent
fe53b9b6ee
commit
d7b713f958
@ -269,23 +269,12 @@ cellConfig ((border, cstyle), dataStyle) =
|
|||||||
DataMixedAmount -> [alignParagraph "end"]
|
DataMixedAmount -> [alignParagraph "end"]
|
||||||
_ -> []
|
_ -> []
|
||||||
)
|
)
|
||||||
cstyleName = cellStyleName cstyle
|
|
||||||
bordName = borderName border
|
|
||||||
style :: String
|
style :: String
|
||||||
style =
|
style =
|
||||||
case dataStyle of
|
let (styleName,dataStyleName) = styleNames cstyle border dataStyle
|
||||||
DataDate ->
|
in printf "style:name='%s'" styleName
|
||||||
printf
|
++
|
||||||
"style:name='%s-%s-date' style:data-style-name='iso-date'"
|
foldMap (printf " style:data-style-name='%s'") dataStyleName
|
||||||
cstyleName bordName
|
|
||||||
DataAmount comm prec ->
|
|
||||||
let name = numberStyleName (comm, prec) in
|
|
||||||
printf
|
|
||||||
"style:name='%s-%s-%s' style:data-style-name='number-%s'"
|
|
||||||
cstyleName bordName name name
|
|
||||||
DataMixedAmount ->
|
|
||||||
printf "style:name='%s-%s-mixedamount'" cstyleName bordName
|
|
||||||
DataString -> printf "style:name='%s-%s'" cstyleName bordName
|
|
||||||
in
|
in
|
||||||
case moreStyles of
|
case moreStyles of
|
||||||
[] ->
|
[] ->
|
||||||
@ -301,20 +290,12 @@ cellConfig ((border, cstyle), dataStyle) =
|
|||||||
formatCell :: Cell Spr.NumLines Text -> [String]
|
formatCell :: Cell Spr.NumLines Text -> [String]
|
||||||
formatCell cell =
|
formatCell cell =
|
||||||
let style, valueType :: String
|
let style, valueType :: String
|
||||||
style = tableStyle styleName
|
style =
|
||||||
cstyleName = cellStyleName $ cellStyle cell
|
printf " table:style-name='%s'" $ fst $
|
||||||
bordName = borderName $ cellBorder cell
|
styleNames
|
||||||
styleName :: String
|
(cellStyle cell)
|
||||||
styleName =
|
(cellBorder cell)
|
||||||
case dataStyleFromType $ cellType cell of
|
(dataStyleFromType $ cellType cell)
|
||||||
DataDate -> printf "%s-%s-date" cstyleName bordName
|
|
||||||
DataAmount comm prec ->
|
|
||||||
let name = numberStyleName (comm, prec) in
|
|
||||||
printf "%s-%s-%s" cstyleName bordName name
|
|
||||||
DataMixedAmount ->
|
|
||||||
printf "%s-%s-mixedamount" cstyleName bordName
|
|
||||||
DataString -> printf "%s-%s" cstyleName bordName
|
|
||||||
tableStyle = printf " table:style-name='%s'"
|
|
||||||
|
|
||||||
valueType =
|
valueType =
|
||||||
case cellType cell of
|
case cellType cell of
|
||||||
@ -354,6 +335,22 @@ formatCell cell =
|
|||||||
printf "</table:%stable-cell>" covered :
|
printf "</table:%stable-cell>" covered :
|
||||||
[]
|
[]
|
||||||
|
|
||||||
|
styleNames ::
|
||||||
|
Style -> Spr.Border Spr.NumLines -> DataStyle -> (String, Maybe String)
|
||||||
|
styleNames cstyle border dataStyle =
|
||||||
|
let cstyleName = cellStyleName cstyle in
|
||||||
|
let bordName = borderName border in
|
||||||
|
case dataStyle of
|
||||||
|
DataDate ->
|
||||||
|
(printf "%s-%s-date" cstyleName bordName, Just "iso-date")
|
||||||
|
DataAmount comm prec ->
|
||||||
|
let name = numberStyleName (comm, prec) in
|
||||||
|
(printf "%s-%s-%s" cstyleName bordName name,
|
||||||
|
Just $ printf "number-%s" name)
|
||||||
|
DataMixedAmount ->
|
||||||
|
(printf "%s-%s-mixedamount" cstyleName bordName, Nothing)
|
||||||
|
DataString -> (printf "%s-%s" cstyleName bordName, Nothing)
|
||||||
|
|
||||||
escape :: String -> String
|
escape :: String -> String
|
||||||
escape =
|
escape =
|
||||||
concatMap $ \c ->
|
concatMap $ \c ->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user