Skip to content

Commit 7bdb9ce

Browse files
committed
WIP
1 parent 7c4ad07 commit 7bdb9ce

File tree

5 files changed

+41
-45
lines changed

5 files changed

+41
-45
lines changed

pub/xlsx/src/Codec/Xlsx/Types/Drawing.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ picture dId fi =
139139
}
140140
shProps =
141141
ShapeProperties
142-
{ _spXfrm = Nothing,
143-
_spGeometry = Nothing,
144-
_spFill = Just NoFill,
145-
_spOutline = Just $ def {_lnFill = Just NoFill}
142+
{ spXfrm = Nothing,
143+
spGeometry = Nothing,
144+
spFill = Just NoFill,
145+
spOutline = Just $ def {_lnFill = Just NoFill}
146146
}
147147

148148
-- | helper to retrive information about all picture files in

pub/xlsx/src/Codec/Xlsx/Types/Drawing/Chart.hs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE DeriveGeneric #-}
33
{-# LANGUAGE OverloadedStrings #-}
44
{-# LANGUAGE RecordWildCards #-}
5-
{-# LANGUAGE TemplateHaskell #-}
65

76
module Codec.Xlsx.Types.Drawing.Chart where
87

@@ -197,8 +196,8 @@ instance NFData ScatterStyle
197196
--
198197
-- See 21.2.2.52 "dPt (Data Point)" (p. 3384)
199198
data DataPoint = DataPoint
200-
{ _dpMarker :: Maybe DataMarker,
201-
_dpShapeProperties :: Maybe ShapeProperties
199+
{ dpMarker :: Maybe DataMarker,
200+
dpShapeProperties :: Maybe ShapeProperties
202201
}
203202
deriving (Eq, Show, Generic)
204203

@@ -358,8 +357,6 @@ data TickMark
358357

359358
instance NFData TickMark
360359

361-
makeLenses ''DataPoint
362-
363360
{-------------------------------------------------------------------------------
364361
Default instances
365362
-------------------------------------------------------------------------------}
@@ -495,8 +492,8 @@ instance FromCursor DataMarker where
495492

496493
instance FromCursor DataPoint where
497494
fromCursor cur = do
498-
_dpMarker <- maybeFromElement (c_ "marker") cur
499-
_dpShapeProperties <- maybeFromElement (c_ "spPr") cur
495+
dpMarker <- maybeFromElement (c_ "marker") cur
496+
dpShapeProperties <- maybeFromElement (c_ "spPr") cur
500497
return DataPoint {..}
501498

502499
instance FromAttrVal DataMarkerSymbol where
@@ -599,7 +596,7 @@ instance ToElement ChartSpace where
599596
where
600597
-- no such element gives a chart space with rounded corners
601598
nonRounded = elementValue "roundedCorners" False
602-
chSpPr = toElement "spPr" $ def {_spFill = Just $ solidRgb "ffffff"}
599+
chSpPr = toElement "spPr" $ def {spFill = Just $ solidRgb "ffffff"}
603600
chartEl = elementListSimple "chart" elements
604601
elements =
605602
catMaybes
@@ -712,7 +709,7 @@ chartToElements chart axId =
712709
toElement "spPr" grayLines,
713710
elementValue "crossAx" cr
714711
]
715-
grayLines = def {_spOutline = Just def {_lnFill = Just $ solidRgb "b3b3b3"}}
712+
grayLines = def {spOutline = Just def {_lnFill = Just $ solidRgb "b3b3b3"}}
716713
gridLinesEl =
717714
elementListSimple "majorGridlines" [toElement "spPr" grayLines]
718715

@@ -821,8 +818,8 @@ instance ToElement PieSeries where
821818
"dPt"
822819
( elementValue "idx" i
823820
: catMaybes
824-
[ toElement "marker" <$> _dpMarker,
825-
toElement "spPr" <$> _dpShapeProperties
821+
[ toElement "marker" <$> dpMarker,
822+
toElement "spPr" <$> dpShapeProperties
826823
]
827824
)
828825

pub/xlsx/src/Codec/Xlsx/Types/Drawing/Common.hs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE DeriveGeneric #-}
33
{-# LANGUAGE OverloadedStrings #-}
44
{-# LANGUAGE RecordWildCards #-}
5-
{-# LANGUAGE TemplateHaskell #-}
65

76
module Codec.Xlsx.Types.Drawing.Common where
87

@@ -290,10 +289,10 @@ instance NFData Geometry
290289

291290
-- See 20.1.2.2.35 "spPr (Shape Properties)" (p. 2751)
292291
data ShapeProperties = ShapeProperties
293-
{ _spXfrm :: Maybe Transform2D,
294-
_spGeometry :: Maybe Geometry,
295-
_spFill :: Maybe FillProperties,
296-
_spOutline :: Maybe LineProperties
292+
{ spXfrm :: Maybe Transform2D,
293+
spGeometry :: Maybe Geometry,
294+
spFill :: Maybe FillProperties,
295+
spOutline :: Maybe LineProperties
297296
-- TODO: bwMode, a_EG_EffectProperties, scene3d, sp3d, extLst
298297
}
299298
deriving (Eq, Show, Generic)
@@ -349,8 +348,6 @@ instance NFData FillProperties
349348
solidRgb :: Text -> FillProperties
350349
solidRgb t = SolidFill . Just $ RgbColor t
351350

352-
makeLenses ''ShapeProperties
353-
354351
{-------------------------------------------------------------------------------
355352
Default instances
356353
-------------------------------------------------------------------------------}
@@ -436,10 +433,10 @@ instance FromAttrVal TextAnchoring where
436433

437434
instance FromCursor ShapeProperties where
438435
fromCursor cur = do
439-
_spXfrm <- maybeFromElement (a_ "xfrm") cur
440-
let _spGeometry = listToMaybe $ cur $/ anyElement >=> fromCursor
441-
_spFill = listToMaybe $ cur $/ anyElement >=> fillPropsFromNode . node
442-
_spOutline <- maybeFromElement (a_ "ln") cur
436+
spXfrm <- maybeFromElement (a_ "xfrm") cur
437+
let spGeometry = listToMaybe $ cur $/ anyElement >=> fromCursor
438+
spFill = listToMaybe $ cur $/ anyElement >=> fillPropsFromNode . node
439+
spOutline <- maybeFromElement (a_ "ln") cur
443440
return ShapeProperties {..}
444441

445442
instance FromCursor Transform2D where
@@ -591,10 +588,10 @@ instance ToElement ShapeProperties where
591588
where
592589
elements =
593590
catMaybes
594-
[ toElement (a_ "xfrm") <$> _spXfrm,
595-
geometryToElement <$> _spGeometry,
596-
fillPropsToElement <$> _spFill,
597-
toElement (a_ "ln") <$> _spOutline
591+
[ toElement (a_ "xfrm") <$> spXfrm,
592+
geometryToElement <$> spGeometry,
593+
fillPropsToElement <$> spFill,
594+
toElement (a_ "ln") <$> spOutline
598595
]
599596

600597
instance ToElement Point2D where

pub/xlsx/test/DrawingTests.hs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Codec.Xlsx.Types.Internal
1919
import Codec.Xlsx.Writer.Internal
2020
import Common
2121
import Data.ByteString.Lazy (ByteString)
22+
import Data.Generics.Labels
2223
import Diff
2324
import Test.Tasty (TestTree, testGroup)
2425
import Test.Tasty.HUnit (testCase)
@@ -86,10 +87,10 @@ testDrawing = Drawing [anchor1, anchor2]
8687
}
8788
shProps =
8889
ShapeProperties
89-
{ _spXfrm = Just trnsfrm,
90-
_spGeometry = Just PresetGeometry,
91-
_spFill = Nothing,
92-
_spOutline = Just $ def {_lnFill = Just NoFill}
90+
{ spXfrm = Just trnsfrm,
91+
spGeometry = Just PresetGeometry,
92+
spFill = Nothing,
93+
spOutline = Just $ def {_lnFill = Just NoFill}
9394
}
9495
trnsfrm =
9596
Transform2D
@@ -306,8 +307,8 @@ testLineChartSpace = oneChartChartSpace lineChart
306307
]
307308
rgbShape color =
308309
def
309-
{ _spFill = Just $ solidRgb color,
310-
_spOutline =
310+
{ spFill = Just $ solidRgb color,
311+
spOutline =
311312
Just $
312313
LineProperties {_lnFill = Just $ solidRgb color, _lnWidth = 28800}
313314
}
@@ -327,8 +328,8 @@ testAreaChartSpace = oneChartChartSpace areaChart
327328
_serShapeProperties =
328329
Just $
329330
def
330-
{ _spFill = Just $ solidRgb "000088",
331-
_spOutline = Just $ def {_lnFill = Just NoFill}
331+
{ spFill = Just $ solidRgb "000088",
332+
spOutline = Just $ def {_lnFill = Just NoFill}
332333
}
333334
},
334335
_arserDataLblProps = Nothing,
@@ -350,8 +351,8 @@ testBarChartSpace =
350351
_serShapeProperties =
351352
Just $
352353
def
353-
{ _spFill = Just $ solidRgb "000088",
354-
_spOutline = Just $ def {_lnFill = Just NoFill}
354+
{ spFill = Just $ solidRgb "000088",
355+
spOutline = Just $ def {_lnFill = Just NoFill}
355356
}
356357
},
357358
_brserDataLblProps = Nothing,
@@ -372,17 +373,17 @@ testPieChartSpace =
372373
_serShapeProperties = Nothing
373374
},
374375
_piserDataPoints =
375-
[ def & dpShapeProperties ?~ solidFill "000088",
376-
def & dpShapeProperties ?~ solidFill "008800",
377-
def & dpShapeProperties ?~ solidFill "880000"
376+
[ def & #dpShapeProperties ?~ solidFill "000088",
377+
def & #dpShapeProperties ?~ solidFill "008800",
378+
def & #dpShapeProperties ?~ solidFill "880000"
378379
],
379380
_piserDataLblProps = Nothing,
380381
_piserVal = Just $ Formula "Sheet1!$B$1:$D$1"
381382
}
382383
]
383384
}
384385
where
385-
solidFill color = def & spFill ?~ solidRgb color
386+
solidFill color = def & #spFill ?~ solidRgb color
386387

387388
testScatterChartSpace :: ChartSpace
388389
testScatterChartSpace =
@@ -395,7 +396,7 @@ testScatterChartSpace =
395396
Series
396397
{ _serTx = Just $ Formula "Sheet1!$A$2",
397398
_serShapeProperties =
398-
Just $ def {_spOutline = Just $ def {_lnFill = Just NoFill}}
399+
Just $ def {spOutline = Just $ def {_lnFill = Just NoFill}}
399400
},
400401
_scserMarker = Just $ DataMarker (Just DataMarkerSquare) Nothing,
401402
_scserDataLblProps = Nothing,

pub/xlsx/xlsx.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ test-suite data-test
197197
, Diff >=0.3.0
198198
, directory
199199
, filepath
200+
, generic-lens
200201
, groom
201202
, mtl
202203
, raw-strings-qq

0 commit comments

Comments
 (0)