5
5
{-# LANGUAGE OverloadedStrings #-}
6
6
{-# LANGUAGE RecordWildCards #-}
7
7
{-# LANGUAGE StandaloneDeriving #-}
8
- {-# LANGUAGE TemplateHaskell #-}
9
8
{-# LANGUAGE TupleSections #-}
10
9
{-# LANGUAGE TypeFamilies #-}
11
10
{-# LANGUAGE TypeSynonymInstances #-}
@@ -38,22 +37,22 @@ import Text.XML.Cursor
38
37
-- | information about image file as a par of a drawing
39
38
data FileInfo = FileInfo
40
39
{ -- | image filename, images are assumed to be stored under path "xl\/media\/"
41
- _fiFilename :: FilePath ,
40
+ fiFilename :: FilePath ,
42
41
-- | image content type, ECMA-376 advises to use "image\/png" or "image\/jpeg"
43
42
-- if interoperability is wanted
44
- _fiContentType :: Text ,
43
+ fiContentType :: Text ,
45
44
-- | image file contents
46
- _fiContents :: ByteString
45
+ fiContents :: ByteString
47
46
}
48
47
deriving (Eq , Show , Generic )
49
48
50
49
instance NFData FileInfo
51
50
52
51
data Marker = Marker
53
- { _mrkCol :: Int ,
54
- _mrkColOff :: Coordinate ,
55
- _mrkRow :: Int ,
56
- _mrkRowOff :: Coordinate
52
+ { mrkCol :: Int ,
53
+ mrkColOff :: Coordinate ,
54
+ mrkRow :: Int ,
55
+ mrkRowOff :: Coordinate
57
56
}
58
57
deriving (Eq , Show , Generic )
59
58
@@ -127,15 +126,15 @@ picture dId fi =
127
126
PicNonVisual $
128
127
NonVisualDrawingProperties
129
128
{ _nvdpId = dId,
130
- _nvdpName = T. pack $ _fiFilename fi,
129
+ _nvdpName = T. pack $ fiFilename fi,
131
130
_nvdpDescription = Nothing ,
132
131
_nvdpHidden = False ,
133
132
_nvdpTitle = Nothing
134
133
}
135
134
bfProps =
136
135
BlipFillProperties
137
- { _bfpImageInfo = Just fi,
138
- _bfpFillMode = Just FillStretch
136
+ { bfpImageInfo = Just fi,
137
+ bfpFillMode = Just FillStretch
139
138
}
140
139
shProps =
141
140
ShapeProperties
@@ -149,11 +148,11 @@ picture dId fi =
149
148
-- particular drawing alongside with their anchorings (i.e. sizes and
150
149
-- positions)
151
150
extractPictures :: Drawing -> [(Anchoring , FileInfo )]
152
- extractPictures dr = mapMaybe maybePictureInfo $ _xdrAnchors dr
151
+ extractPictures dr = mapMaybe maybePictureInfo $ xdrAnchors dr
153
152
where
154
153
maybePictureInfo Anchor {.. } =
155
- case _anchObject of
156
- Picture {.. } -> (_anchAnchoring ,) <$> _bfpImageInfo _picBlipFill
154
+ case anchObject of
155
+ Picture {.. } -> (anchAnchoring ,) <$> bfpImageInfo _picBlipFill
157
156
_ -> Nothing
158
157
159
158
-- | This element is used to set certain properties related to a drawing
@@ -216,8 +215,8 @@ data NonVisualDrawingProperties = NonVisualDrawingProperties
216
215
instance NFData NonVisualDrawingProperties
217
216
218
217
data BlipFillProperties a = BlipFillProperties
219
- { _bfpImageInfo :: Maybe a ,
220
- _bfpFillMode :: Maybe FillMode
218
+ { bfpImageInfo :: Maybe a ,
219
+ bfpFillMode :: Maybe FillMode
221
220
-- TODO: dpi, rotWithShape, srcRect
222
221
}
223
222
deriving (Eq , Show , Generic )
@@ -236,16 +235,16 @@ instance NFData FillMode
236
235
237
236
-- See @EG_Anchor@ (p. 4052)
238
237
data Anchor p g = Anchor
239
- { _anchAnchoring :: Anchoring ,
240
- _anchObject :: DrawingObject p g ,
241
- _anchClientData :: ClientData
238
+ { anchAnchoring :: Anchoring ,
239
+ anchObject :: DrawingObject p g ,
240
+ anchClientData :: ClientData
242
241
}
243
242
deriving (Eq , Show , Generic )
244
243
245
244
instance (NFData p , NFData g ) => NFData (Anchor p g )
246
245
247
246
data GenericDrawing p g = Drawing
248
- { _xdrAnchors :: [Anchor p g ]
247
+ { xdrAnchors :: [Anchor p g ]
249
248
}
250
249
deriving (Eq , Show , Generic )
251
250
@@ -256,11 +255,6 @@ type Drawing = GenericDrawing FileInfo ChartSpace
256
255
257
256
type UnresolvedDrawing = GenericDrawing RefId RefId
258
257
259
- makeLenses ''Anchor
260
- makeLenses ''DrawingObject
261
- makeLenses ''BlipFillProperties
262
- makeLenses ''GenericDrawing
263
-
264
258
-- | simple drawing object anchoring using one cell as a top lelft
265
259
-- corner and dimensions of that object
266
260
simpleAnchorXY ::
@@ -274,10 +268,10 @@ simpleAnchorXY ::
274
268
Anchor p g
275
269
simpleAnchorXY (x, y) sz obj =
276
270
Anchor
277
- { _anchAnchoring =
271
+ { anchAnchoring =
278
272
OneCellAnchor {onecaFrom = unqMarker (x, 0 ) (y, 0 ), onecaExt = sz},
279
- _anchObject = obj,
280
- _anchClientData = def
273
+ anchObject = obj,
274
+ anchClientData = def
281
275
}
282
276
283
277
{- ------------------------------------------------------------------------------
@@ -296,9 +290,9 @@ instance FromCursor UnresolvedDrawing where
296
290
297
291
instance FromCursor (Anchor RefId RefId ) where
298
292
fromCursor cur = do
299
- _anchAnchoring <- fromCursor cur
300
- _anchObject <- cur $/ anyElement >=> fromCursor
301
- _anchClientData <- cur $/ element (xdr " clientData" ) >=> fromCursor
293
+ anchAnchoring <- fromCursor cur
294
+ anchObject <- cur $/ anyElement >=> fromCursor
295
+ anchClientData <- cur $/ element (xdr " clientData" ) >=> fromCursor
302
296
return Anchor {.. }
303
297
304
298
instance FromCursor Anchoring where
@@ -325,10 +319,10 @@ anchoringFromNode n
325
319
326
320
instance FromCursor Marker where
327
321
fromCursor cur = do
328
- _mrkCol <- cur $/ element (xdr " col" ) &/ content >=> decimal
329
- _mrkColOff <- cur $/ element (xdr " colOff" ) &/ content >=> coordinate
330
- _mrkRow <- cur $/ element (xdr " row" ) &/ content >=> decimal
331
- _mrkRowOff <- cur $/ element (xdr " rowOff" ) &/ content >=> coordinate
322
+ mrkCol <- cur $/ element (xdr " col" ) &/ content >=> decimal
323
+ mrkColOff <- cur $/ element (xdr " colOff" ) &/ content >=> coordinate
324
+ mrkRow <- cur $/ element (xdr " row" ) &/ content >=> decimal
325
+ mrkRowOff <- cur $/ element (xdr " rowOff" ) &/ content >=> coordinate
332
326
return Marker {.. }
333
327
334
328
instance FromCursor (DrawingObject RefId RefId ) where
@@ -382,12 +376,12 @@ instance FromAttrVal DrawingElementId where
382
376
383
377
instance FromCursor (BlipFillProperties RefId ) where
384
378
fromCursor cur = do
385
- let _bfpImageInfo =
379
+ let bfpImageInfo =
386
380
listToMaybe $
387
381
cur
388
382
$/ element (a_ " blip" )
389
383
>=> fmap RefId . attribute (odr " embed" )
390
- _bfpFillMode = listToMaybe $ cur $/ anyElement >=> fromCursor
384
+ bfpFillMode = listToMaybe $ cur $/ anyElement >=> fromCursor
391
385
return BlipFillProperties {.. }
392
386
393
387
instance FromCursor FillMode where
@@ -439,9 +433,9 @@ anchorToElement Anchor {..} =
439
433
++ map NodeElement [drawingObjEl, cdEl]
440
434
}
441
435
where
442
- el = anchoringToElement _anchAnchoring
443
- drawingObjEl = drawingObjToElement _anchObject
444
- cdEl = toElement " clientData" _anchClientData
436
+ el = anchoringToElement anchAnchoring
437
+ drawingObjEl = drawingObjToElement anchObject
438
+ cdEl = toElement " clientData" anchClientData
445
439
446
440
anchoringToElement :: Anchoring -> Element
447
441
anchoringToElement anchoring = elementList nm attrs elements
@@ -467,10 +461,10 @@ instance ToElement Marker where
467
461
toElement nm Marker {.. } = elementListSimple nm elements
468
462
where
469
463
elements =
470
- [ elementContent " col" (toAttrVal _mrkCol ),
471
- elementContent " colOff" (toAttrVal _mrkColOff ),
472
- elementContent " row" (toAttrVal _mrkRow ),
473
- elementContent " rowOff" (toAttrVal _mrkRowOff )
464
+ [ elementContent " col" (toAttrVal mrkCol ),
465
+ elementContent " colOff" (toAttrVal mrkColOff ),
466
+ elementContent " row" (toAttrVal mrkRow ),
467
+ elementContent " rowOff" (toAttrVal mrkRowOff )
474
468
]
475
469
476
470
drawingObjToElement :: DrawingObject RefId RefId -> Element
@@ -534,8 +528,8 @@ instance ToElement (BlipFillProperties RefId) where
534
528
where
535
529
elements =
536
530
catMaybes
537
- [ (\ rId -> leafElement (a_ " blip" ) [odr " embed" .= rId]) <$> _bfpImageInfo ,
538
- fillModeToElement <$> _bfpFillMode
531
+ [ (\ rId -> leafElement (a_ " blip" ) [odr " embed" .= rId]) <$> bfpImageInfo ,
532
+ fillModeToElement <$> bfpFillMode
539
533
]
540
534
541
535
fillModeToElement :: FillMode -> Element
0 commit comments