@@ -60,11 +60,11 @@ data FormattingState = FormattingState
60
60
stateFromStyleSheet :: StyleSheet -> FormattingState
61
61
stateFromStyleSheet StyleSheet {.. } =
62
62
FormattingState
63
- { formattingBorders = fromValueList _styleSheetBorders ,
64
- formattingCellXfs = fromValueList _styleSheetCellXfs ,
65
- formattingFills = fromValueList _styleSheetFills ,
66
- formattingFonts = fromValueList _styleSheetFonts ,
67
- formattingNumFmts = M. fromList . map swap $ M. toList _styleSheetNumFmts ,
63
+ { formattingBorders = fromValueList styleSheetBorders ,
64
+ formattingCellXfs = fromValueList styleSheetCellXfs ,
65
+ formattingFills = fromValueList styleSheetFills ,
66
+ formattingFonts = fromValueList styleSheetFonts ,
67
+ formattingNumFmts = M. fromList . map swap $ M. toList styleSheetNumFmts ,
68
68
formattingMerges = []
69
69
}
70
70
@@ -77,11 +77,11 @@ toValueList = map snd . sortBy (comparing fst) . map swap . M.toList
77
77
updateStyleSheetFromState :: StyleSheet -> FormattingState -> StyleSheet
78
78
updateStyleSheetFromState sSheet FormattingState {.. } =
79
79
sSheet
80
- { _styleSheetBorders = toValueList formattingBorders,
81
- _styleSheetCellXfs = toValueList formattingCellXfs,
82
- _styleSheetFills = toValueList formattingFills,
83
- _styleSheetFonts = toValueList formattingFonts,
84
- _styleSheetNumFmts = M. fromList . map swap $ M. toList formattingNumFmts
80
+ { styleSheetBorders = toValueList formattingBorders,
81
+ styleSheetCellXfs = toValueList formattingCellXfs,
82
+ styleSheetFills = toValueList formattingFills,
83
+ styleSheetFonts = toValueList formattingFonts,
84
+ styleSheetNumFmts = M. fromList . map swap $ M. toList formattingNumFmts
85
85
}
86
86
87
87
getId ::
@@ -123,8 +123,8 @@ data FormattedCondFmt = FormattedCondFmt
123
123
--
124
124
-- TODOs:
125
125
--
126
- -- * Add a number format ('_cellXfApplyNumberFormat ', '_cellXfNumFmtId ')
127
- -- * Add references to the named style sheets ('_cellXfId ')
126
+ -- * Add a number format ('cellXfApplyNumberFormat ', 'cellXfNumFmtId ')
127
+ -- * Add references to the named style sheets ('cellXfId ')
128
128
data Format = Format
129
129
{ formatAlignment :: Maybe Alignment ,
130
130
formatBorder :: Maybe Border ,
@@ -201,7 +201,7 @@ data Formatted = Formatted
201
201
-- This has a number of causes:
202
202
--
203
203
-- * The 'Cell' datatype wants an 'Int' for the style, which is supposed to
204
- -- point into the '_styleSheetCellXfs ' part of a stylesheet. However, this can
204
+ -- point into the 'styleSheetCellXfs ' part of a stylesheet. However, this can
205
205
-- be difficult to work with, as it requires manual tracking of cell style
206
206
-- IDs, which in turns requires manual tracking of font IDs, border IDs, etc.
207
207
-- * Row-span and column-span properties are set on the worksheet as a whole
@@ -272,33 +272,33 @@ toFormattedCells m merges StyleSheet {..} = applyMerges $ M.map toFormattedCell
272
272
}
273
273
formatFromStyle cellXf =
274
274
Format
275
- { formatAlignment = applied _cellXfApplyAlignment _cellXfAlignment cellXf,
275
+ { formatAlignment = applied cellXfApplyAlignment cellXfAlignment cellXf,
276
276
formatBorder =
277
277
flip M. lookup borders
278
- =<< applied _cellXfApplyBorder _cellXfBorderId cellXf,
278
+ =<< applied cellXfApplyBorder cellXfBorderId cellXf,
279
279
formatFill =
280
280
flip M. lookup fills
281
- =<< applied _cellXfApplyFill _cellXfFillId cellXf,
281
+ =<< applied cellXfApplyFill cellXfFillId cellXf,
282
282
formatFont =
283
283
flip M. lookup fonts
284
- =<< applied _cellXfApplyFont _cellXfFontId cellXf,
284
+ =<< applied cellXfApplyFont cellXfFontId cellXf,
285
285
formatNumberFormat =
286
286
lookupNumFmt
287
- =<< applied _cellXfApplyNumberFormat _cellXfNumFmtId cellXf,
288
- formatProtection = _cellXfProtection cellXf,
289
- formatPivotButton = _cellXfPivotButton cellXf,
290
- formatQuotePrefix = _cellXfQuotePrefix cellXf
287
+ =<< applied cellXfApplyNumberFormat cellXfNumFmtId cellXf,
288
+ formatProtection = cellXfProtection cellXf,
289
+ formatPivotButton = cellXfPivotButton cellXf,
290
+ formatQuotePrefix = cellXfQuotePrefix cellXf
291
291
}
292
292
idMapped :: [a ] -> Map Int a
293
293
idMapped = M. fromList . zip [0 .. ]
294
- cellXfs = idMapped _styleSheetCellXfs
295
- borders = idMapped _styleSheetBorders
296
- fills = idMapped _styleSheetFills
297
- fonts = idMapped _styleSheetFonts
294
+ cellXfs = idMapped styleSheetCellXfs
295
+ borders = idMapped styleSheetBorders
296
+ fills = idMapped styleSheetFills
297
+ fonts = idMapped styleSheetFonts
298
298
lookupNumFmt fId =
299
299
asum
300
300
[ StdNumberFormat <$> idToStdNumberFormat fId,
301
- UserNumberFormat <$> M. lookup fId _styleSheetNumFmts
301
+ UserNumberFormat <$> M. lookup fId styleSheetNumFmts
302
302
]
303
303
applied :: (CellXf -> Maybe Bool ) -> (CellXf -> Maybe a ) -> CellXf -> Maybe a
304
304
applied applyProp prop cXf = do
@@ -331,12 +331,12 @@ conditionallyFormatted ::
331
331
Map CellRef [FormattedCondFmt ] -> StyleSheet -> CondFormatted
332
332
conditionallyFormatted cfs styleSheet =
333
333
CondFormatted
334
- { condformattedStyleSheet = styleSheet & styleSheetDxfs .~ finalDxfs,
334
+ { condformattedStyleSheet = styleSheet & # styleSheetDxfs .~ finalDxfs,
335
335
condformattedFormattings = fmts
336
336
}
337
337
where
338
338
(cellFmts, dxf2id ) = runState (mapM (mapM mapDxf) cfs) dxf2id0
339
- dxf2id0 = fromValueList (styleSheet ^. styleSheetDxfs)
339
+ dxf2id0 = fromValueList (styleSheet ^. # styleSheetDxfs)
340
340
fmts =
341
341
M. fromList
342
342
. map mergeSqRef
@@ -408,14 +408,14 @@ cellBlock (row, col) cell@FormattedCell {..} = (block, merge)
408
408
borderAt :: (RowIndex , ColumnIndex ) -> Border
409
409
borderAt (row', col') =
410
410
def
411
- & borderTop
412
- .~ do guard (row' == topRow); _borderTop =<< border
413
- & borderBottom
414
- .~ do guard (row' == bottomRow); _borderBottom =<< border
415
- & borderLeft
416
- .~ do guard (col' == leftCol); _borderLeft =<< border
417
- & borderRight
418
- .~ do guard (col' == rightCol); _borderRight =<< border
411
+ & # borderTop
412
+ .~ do guard (row' == topRow); borderTop =<< border
413
+ & # borderBottom
414
+ .~ do guard (row' == bottomRow); borderBottom =<< border
415
+ & # borderLeft
416
+ .~ do guard (col' == leftCol); borderLeft =<< border
417
+ & # borderRight
418
+ .~ do guard (col' == rightCol); borderRight =<< border
419
419
420
420
topRow , bottomRow :: RowIndex
421
421
leftCol , rightCol :: ColumnIndex
@@ -441,21 +441,21 @@ constructCellXf FormattedCell {formattedFormat = Format {..}} = do
441
441
mNumFmtId <- getFmtId # formattingNumFmts `mapM` formatNumberFormat
442
442
let xf =
443
443
CellXf
444
- { _cellXfApplyAlignment = apply formatAlignment,
445
- _cellXfApplyBorder = apply mBorderId,
446
- _cellXfApplyFill = apply mFillId,
447
- _cellXfApplyFont = apply mFontId,
448
- _cellXfApplyNumberFormat = apply formatNumberFormat,
449
- _cellXfApplyProtection = apply formatProtection,
450
- _cellXfBorderId = mBorderId,
451
- _cellXfFillId = mFillId,
452
- _cellXfFontId = mFontId,
453
- _cellXfNumFmtId = mNumFmtId,
454
- _cellXfPivotButton = formatPivotButton,
455
- _cellXfQuotePrefix = formatQuotePrefix,
456
- _cellXfId = Nothing , -- TODO
457
- _cellXfAlignment = formatAlignment,
458
- _cellXfProtection = formatProtection
444
+ { cellXfApplyAlignment = apply formatAlignment,
445
+ cellXfApplyBorder = apply mBorderId,
446
+ cellXfApplyFill = apply mFillId,
447
+ cellXfApplyFont = apply mFontId,
448
+ cellXfApplyNumberFormat = apply formatNumberFormat,
449
+ cellXfApplyProtection = apply formatProtection,
450
+ cellXfBorderId = mBorderId,
451
+ cellXfFillId = mFillId,
452
+ cellXfFontId = mFontId,
453
+ cellXfNumFmtId = mNumFmtId,
454
+ cellXfPivotButton = formatPivotButton,
455
+ cellXfQuotePrefix = formatQuotePrefix,
456
+ cellXfId = Nothing , -- TODO
457
+ cellXfAlignment = formatAlignment,
458
+ cellXfProtection = formatProtection
459
459
}
460
460
return $ if xf == def then Nothing else Just xf
461
461
where
0 commit comments