    {-# LANGUAGE CPP #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE RecordWildCards #-}
    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE DeriveGeneric #-}
    module Codec.Xlsx.Types.Drawing.Common where

    import GHC.Generics (Generic)

    import Control.Arrow (first)
    #ifdef USE_MICROLENS
    import Lens.Micro.TH (makeLenses)
    #else
    import Control.Lens.TH
    #endif
    import Control.Monad (join)
    import Control.Monad.Fail (MonadFail)
    import Control.DeepSeq (NFData)
    import Data.Default
    import Data.Maybe (catMaybes, listToMaybe)
    import Data.Monoid ((<>))
    import Data.Text (Text)
    import qualified Data.Text as T
    import qualified Data.Text.Read as T
    import Text.XML
    import Text.XML.Cursor

    import Codec.Xlsx.Parser.Internal
    import Codec.Xlsx.Writer.Internal

    -- | This simple type represents an angle in 60,000ths of a degree.
    -- Positive angles are clockwise (i.e., towards the positive y axis); negative
    -- angles are counter-clockwise (i.e., towards the negative y axis).
    newtype Angle =
      Angle Int
      deriving (Angle -> Angle -> Bool
    (Angle -> Angle -> Bool) -> (Angle -> Angle -> Bool) -> Eq Angle
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Angle -> Angle -> Bool
    == :: Angle -> Angle -> Bool
    $c/= :: Angle -> Angle -> Bool
    /= :: Angle -> Angle -> Bool
    Eq, Int -> Angle -> ShowS
    [Angle] -> ShowS
    Angle -> String
    (Int -> Angle -> ShowS)
    -> (Angle -> String) -> ([Angle] -> ShowS) -> Show Angle
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Angle -> ShowS
    showsPrec :: Int -> Angle -> ShowS
    $cshow :: Angle -> String
    show :: Angle -> String
    $cshowList :: [Angle] -> ShowS
    showList :: [Angle] -> ShowS
    Show, (forall x. Angle -> Rep Angle x)
    -> (forall x. Rep Angle x -> Angle) -> Generic Angle
    forall x. Rep Angle x -> Angle
    forall x. Angle -> Rep Angle x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Angle -> Rep Angle x
    from :: forall x. Angle -> Rep Angle x
    $cto :: forall x. Rep Angle x -> Angle
    to :: forall x. Rep Angle x -> Angle
    Generic)
    instance NFData Angle

    -- | A string with rich text formatting
    --
    -- TODO: horzOverflow, lIns, tIns, rIns, bIns, numCol, spcCol, rtlCol,
    --   fromWordArt, forceAA, upright, compatLnSpc, prstTxWarp,
    --   a_EG_TextAutofit, scene3d, a_EG_Text3D, extLst
    --
    -- See @CT_TextBody@ (p. 4034)
    data TextBody = TextBody
      { TextBody -> Angle
    _txbdRotation :: Angle
        -- ^ Specifies the rotation that is being applied to the text within the bounding box.
      , TextBody -> Bool
    _txbdSpcFirstLastPara :: Bool
        -- ^ Specifies whether the before and after paragraph spacing defined by the user is
        -- to be respected.
      , TextBody -> TextVertOverflow
    _txbdVertOverflow :: TextVertOverflow
        -- ^ Determines whether the text can flow out of the bounding box vertically.
      , TextBody -> TextVertical
    _txbdVertical :: TextVertical
        -- ^ Determines if the text within the given text body should be displayed vertically.
      , TextBody -> TextWrap
    _txbdWrap :: TextWrap
        -- ^ Specifies the wrapping options to be used for this text body.
      , TextBody -> TextAnchoring
    _txbdAnchor :: TextAnchoring
        -- ^ Specifies the anchoring position of the txBody within the shape.
      , TextBody -> Bool
    _txbdAnchorCenter :: Bool
        -- ^ Specifies the centering of the text box. The way it works fundamentally is
        -- to determine the smallest possible "bounds box" for the text and then to center
        -- that "bounds box" accordingly. This is different than paragraph alignment, which
        -- aligns the text within the "bounds box" for the text.
      , TextBody -> [TextParagraph]
    _txbdParagraphs :: [TextParagraph]
        -- ^ Paragraphs of text within the containing text body
      } deriving (TextBody -> TextBody -> Bool
    (TextBody -> TextBody -> Bool)
    -> (TextBody -> TextBody -> Bool) -> Eq TextBody
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextBody -> TextBody -> Bool
    == :: TextBody -> TextBody -> Bool
    $c/= :: TextBody -> TextBody -> Bool
    /= :: TextBody -> TextBody -> Bool
    Eq, Int -> TextBody -> ShowS
    [TextBody] -> ShowS
    TextBody -> String
    (Int -> TextBody -> ShowS)
    -> (TextBody -> String) -> ([TextBody] -> ShowS) -> Show TextBody
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextBody -> ShowS
    showsPrec :: Int -> TextBody -> ShowS
    $cshow :: TextBody -> String
    show :: TextBody -> String
    $cshowList :: [TextBody] -> ShowS
    showList :: [TextBody] -> ShowS
    Show, (forall x. TextBody -> Rep TextBody x)
    -> (forall x. Rep TextBody x -> TextBody) -> Generic TextBody
    forall x. Rep TextBody x -> TextBody
    forall x. TextBody -> Rep TextBody x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextBody -> Rep TextBody x
    from :: forall x. TextBody -> Rep TextBody x
    $cto :: forall x. Rep TextBody x -> TextBody
    to :: forall x. Rep TextBody x -> TextBody
    Generic)
    instance NFData TextBody

    -- | Text vertical overflow
    -- See 20.1.10.83 "ST_TextVertOverflowType (Text Vertical Overflow)" (p. 3083)
    data TextVertOverflow
      = TextVertOverflowClip
        -- ^ Pay attention to top and bottom barriers. Provide no indication that there is
        -- text which is not visible.
      | TextVertOverflowEllipsis
        -- ^ Pay attention to top and bottom barriers. Use an ellipsis to denote that
        -- there is text which is not visible.
      | TextVertOverflow
        -- ^ Overflow the text and pay no attention to top and bottom barriers.
      deriving (TextVertOverflow -> TextVertOverflow -> Bool
    (TextVertOverflow -> TextVertOverflow -> Bool)
    -> (TextVertOverflow -> TextVertOverflow -> Bool)
    -> Eq TextVertOverflow
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextVertOverflow -> TextVertOverflow -> Bool
    == :: TextVertOverflow -> TextVertOverflow -> Bool
    $c/= :: TextVertOverflow -> TextVertOverflow -> Bool
    /= :: TextVertOverflow -> TextVertOverflow -> Bool
    Eq, Int -> TextVertOverflow -> ShowS
    [TextVertOverflow] -> ShowS
    TextVertOverflow -> String
    (Int -> TextVertOverflow -> ShowS)
    -> (TextVertOverflow -> String)
    -> ([TextVertOverflow] -> ShowS)
    -> Show TextVertOverflow
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextVertOverflow -> ShowS
    showsPrec :: Int -> TextVertOverflow -> ShowS
    $cshow :: TextVertOverflow -> String
    show :: TextVertOverflow -> String
    $cshowList :: [TextVertOverflow] -> ShowS
    showList :: [TextVertOverflow] -> ShowS
    Show, (forall x. TextVertOverflow -> Rep TextVertOverflow x)
    -> (forall x. Rep TextVertOverflow x -> TextVertOverflow)
    -> Generic TextVertOverflow
    forall x. Rep TextVertOverflow x -> TextVertOverflow
    forall x. TextVertOverflow -> Rep TextVertOverflow x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextVertOverflow -> Rep TextVertOverflow x
    from :: forall x. TextVertOverflow -> Rep TextVertOverflow x
    $cto :: forall x. Rep TextVertOverflow x -> TextVertOverflow
    to :: forall x. Rep TextVertOverflow x -> TextVertOverflow
    Generic)
    instance NFData TextVertOverflow

    -- | If there is vertical text, determines what kind of vertical text is going to be used.
    --
    --  See 20.1.10.82 "ST_TextVerticalType (Vertical Text Types)" (p. 3083)
    data TextVertical
      = TextVerticalEA
        -- ^ A special version of vertical text, where some fonts are displayed as if rotated
        -- by 90 degrees while some fonts (mostly East Asian) are displayed vertical.
      | TextVerticalHorz
        -- ^ Horizontal text. This should be default.
      | TextVerticalMongolian
        -- ^ A special version of vertical text, where some fonts are displayed as if rotated
        -- by 90 degrees while some fonts (mostly East Asian) are displayed vertical. The
        -- difference between this and the 'TextVerticalEA' is the text flows top down then
        -- LEFT RIGHT, instead of RIGHT LEFT
      | TextVertical
        -- ^ Determines if all of the text is vertical orientation (each line is 90 degrees
        -- rotated clockwise, so it goes from top to bottom; each next line is to the left
        -- from the previous one).
      | TextVertical270
        -- ^ Determines if all of the text is vertical orientation (each line is 270 degrees
        -- rotated clockwise, so it goes from bottom to top; each next line is to the right
        -- from the previous one).
      | TextVerticalWordArt
        -- ^ Determines if all of the text is vertical ("one letter on top of another").
      | TextVerticalWordArtRtl
        -- ^  Specifies that vertical WordArt should be shown from right to left rather than
        -- left to right.
      deriving (TextVertical -> TextVertical -> Bool
    (TextVertical -> TextVertical -> Bool)
    -> (TextVertical -> TextVertical -> Bool) -> Eq TextVertical
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextVertical -> TextVertical -> Bool
    == :: TextVertical -> TextVertical -> Bool
    $c/= :: TextVertical -> TextVertical -> Bool
    /= :: TextVertical -> TextVertical -> Bool
    Eq, Int -> TextVertical -> ShowS
    [TextVertical] -> ShowS
    TextVertical -> String
    (Int -> TextVertical -> ShowS)
    -> (TextVertical -> String)
    -> ([TextVertical] -> ShowS)
    -> Show TextVertical
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextVertical -> ShowS
    showsPrec :: Int -> TextVertical -> ShowS
    $cshow :: TextVertical -> String
    show :: TextVertical -> String
    $cshowList :: [TextVertical] -> ShowS
    showList :: [TextVertical] -> ShowS
    Show, (forall x. TextVertical -> Rep TextVertical x)
    -> (forall x. Rep TextVertical x -> TextVertical)
    -> Generic TextVertical
    forall x. Rep TextVertical x -> TextVertical
    forall x. TextVertical -> Rep TextVertical x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextVertical -> Rep TextVertical x
    from :: forall x. TextVertical -> Rep TextVertical x
    $cto :: forall x. Rep TextVertical x -> TextVertical
    to :: forall x. Rep TextVertical x -> TextVertical
    Generic)
    instance NFData TextVertical

    -- | Text wrapping types
    --
    -- See 20.1.10.84 "ST_TextWrappingType (Text Wrapping Types)" (p. 3084)
    data TextWrap
        = TextWrapNone
        -- ^ No wrapping occurs on this text body. Words spill out without
        -- paying attention to the bounding rectangle boundaries.
        | TextWrapSquare
        -- ^ Determines whether we wrap words within the bounding rectangle.
        deriving (TextWrap -> TextWrap -> Bool
    (TextWrap -> TextWrap -> Bool)
    -> (TextWrap -> TextWrap -> Bool) -> Eq TextWrap
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextWrap -> TextWrap -> Bool
    == :: TextWrap -> TextWrap -> Bool
    $c/= :: TextWrap -> TextWrap -> Bool
    /= :: TextWrap -> TextWrap -> Bool
    Eq, Int -> TextWrap -> ShowS
    [TextWrap] -> ShowS
    TextWrap -> String
    (Int -> TextWrap -> ShowS)
    -> (TextWrap -> String) -> ([TextWrap] -> ShowS) -> Show TextWrap
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextWrap -> ShowS
    showsPrec :: Int -> TextWrap -> ShowS
    $cshow :: TextWrap -> String
    show :: TextWrap -> String
    $cshowList :: [TextWrap] -> ShowS
    showList :: [TextWrap] -> ShowS
    Show, (forall x. TextWrap -> Rep TextWrap x)
    -> (forall x. Rep TextWrap x -> TextWrap) -> Generic TextWrap
    forall x. Rep TextWrap x -> TextWrap
    forall x. TextWrap -> Rep TextWrap x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextWrap -> Rep TextWrap x
    from :: forall x. TextWrap -> Rep TextWrap x
    $cto :: forall x. Rep TextWrap x -> TextWrap
    to :: forall x. Rep TextWrap x -> TextWrap
    Generic)
    instance NFData TextWrap

    -- | This type specifies a list of available anchoring types for text.
    --
    -- See 20.1.10.59 "ST_TextAnchoringType (Text Anchoring Types)" (p. 3058)
    data TextAnchoring
      = TextAnchoringBottom
        -- ^ Anchor the text at the bottom of the bounding rectangle.
      | TextAnchoringCenter
        -- ^ Anchor the text at the middle of the bounding rectangle.
      | TextAnchoringDistributed
        -- ^  Anchor the text so that it is distributed vertically. When text is horizontal,
        -- this spaces out the actual lines of text and is almost always identical in
        -- behavior to 'TextAnchoringJustified' (special case: if only 1 line, then anchored
        -- in middle). When text is vertical, then it distributes the letters vertically.
        -- This is different than 'TextAnchoringJustified', because it always forces distribution
        -- of the words, even if there are only one or two words in a line.
      | TextAnchoringJustified
        -- ^ Anchor the text so that it is justified vertically. When text is horizontal,
        -- this spaces out the actual lines of text and is almost always identical in
        -- behavior to 'TextAnchoringDistributed' (special case: if only 1 line, then anchored at
        -- top). When text is vertical, then it justifies the letters vertically. This is
        -- different than 'TextAnchoringDistributed' because in some cases such as very little
        -- text in a line, it does not justify.
      | TextAnchoringTop
        -- ^ Anchor the text at the top of the bounding rectangle.
      deriving (TextAnchoring -> TextAnchoring -> Bool
    (TextAnchoring -> TextAnchoring -> Bool)
    -> (TextAnchoring -> TextAnchoring -> Bool) -> Eq TextAnchoring
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextAnchoring -> TextAnchoring -> Bool
    == :: TextAnchoring -> TextAnchoring -> Bool
    $c/= :: TextAnchoring -> TextAnchoring -> Bool
    /= :: TextAnchoring -> TextAnchoring -> Bool
    Eq, Int -> TextAnchoring -> ShowS
    [TextAnchoring] -> ShowS
    TextAnchoring -> String
    (Int -> TextAnchoring -> ShowS)
    -> (TextAnchoring -> String)
    -> ([TextAnchoring] -> ShowS)
    -> Show TextAnchoring
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextAnchoring -> ShowS
    showsPrec :: Int -> TextAnchoring -> ShowS
    $cshow :: TextAnchoring -> String
    show :: TextAnchoring -> String
    $cshowList :: [TextAnchoring] -> ShowS
    showList :: [TextAnchoring] -> ShowS
    Show, (forall x. TextAnchoring -> Rep TextAnchoring x)
    -> (forall x. Rep TextAnchoring x -> TextAnchoring)
    -> Generic TextAnchoring
    forall x. Rep TextAnchoring x -> TextAnchoring
    forall x. TextAnchoring -> Rep TextAnchoring x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextAnchoring -> Rep TextAnchoring x
    from :: forall x. TextAnchoring -> Rep TextAnchoring x
    $cto :: forall x. Rep TextAnchoring x -> TextAnchoring
    to :: forall x. Rep TextAnchoring x -> TextAnchoring
    Generic)
    instance NFData TextAnchoring

    -- See 21.1.2.2.6 "p (Text Paragraphs)" (p. 3211)
    data TextParagraph = TextParagraph
      { TextParagraph -> Maybe TextCharacterProperties
    _txpaDefCharProps :: Maybe TextCharacterProperties
      , TextParagraph -> [TextRun]
    _txpaRuns :: [TextRun]
      } deriving (TextParagraph -> TextParagraph -> Bool
    (TextParagraph -> TextParagraph -> Bool)
    -> (TextParagraph -> TextParagraph -> Bool) -> Eq TextParagraph
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextParagraph -> TextParagraph -> Bool
    == :: TextParagraph -> TextParagraph -> Bool
    $c/= :: TextParagraph -> TextParagraph -> Bool
    /= :: TextParagraph -> TextParagraph -> Bool
    Eq, Int -> TextParagraph -> ShowS
    [TextParagraph] -> ShowS
    TextParagraph -> String
    (Int -> TextParagraph -> ShowS)
    -> (TextParagraph -> String)
    -> ([TextParagraph] -> ShowS)
    -> Show TextParagraph
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextParagraph -> ShowS
    showsPrec :: Int -> TextParagraph -> ShowS
    $cshow :: TextParagraph -> String
    show :: TextParagraph -> String
    $cshowList :: [TextParagraph] -> ShowS
    showList :: [TextParagraph] -> ShowS
    Show, (forall x. TextParagraph -> Rep TextParagraph x)
    -> (forall x. Rep TextParagraph x -> TextParagraph)
    -> Generic TextParagraph
    forall x. Rep TextParagraph x -> TextParagraph
    forall x. TextParagraph -> Rep TextParagraph x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextParagraph -> Rep TextParagraph x
    from :: forall x. TextParagraph -> Rep TextParagraph x
    $cto :: forall x. Rep TextParagraph x -> TextParagraph
    to :: forall x. Rep TextParagraph x -> TextParagraph
    Generic)
    instance NFData TextParagraph

    -- | Text character properties
    --
    -- TODO: kumimoji, lang, altLang, sz, strike, kern, cap, spc,
    --   normalizeH, baseline, noProof, dirty, err, smtClean, smtId,
    --   bmk, ln, a_EG_FillProperties, a_EG_EffectProperties, highlight,
    --   a_EG_TextUnderlineLine, a_EG_TextUnderlineFill, latin, ea, cs,
    --   sym, hlinkClick, hlinkMouseOver, rtl, extLst
    --
    -- See @CT_TextCharacterProperties@ (p. 4039)
    data TextCharacterProperties = TextCharacterProperties
      { TextCharacterProperties -> Bool
    _txchBold :: Bool
      , TextCharacterProperties -> Bool
    _txchItalic :: Bool
      , TextCharacterProperties -> Bool
    _txchUnderline :: Bool
      } deriving (TextCharacterProperties -> TextCharacterProperties -> Bool
    (TextCharacterProperties -> TextCharacterProperties -> Bool)
    -> (TextCharacterProperties -> TextCharacterProperties -> Bool)
    -> Eq TextCharacterProperties
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextCharacterProperties -> TextCharacterProperties -> Bool
    == :: TextCharacterProperties -> TextCharacterProperties -> Bool
    $c/= :: TextCharacterProperties -> TextCharacterProperties -> Bool
    /= :: TextCharacterProperties -> TextCharacterProperties -> Bool
    Eq, Int -> TextCharacterProperties -> ShowS
    [TextCharacterProperties] -> ShowS
    TextCharacterProperties -> String
    (Int -> TextCharacterProperties -> ShowS)
    -> (TextCharacterProperties -> String)
    -> ([TextCharacterProperties] -> ShowS)
    -> Show TextCharacterProperties
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextCharacterProperties -> ShowS
    showsPrec :: Int -> TextCharacterProperties -> ShowS
    $cshow :: TextCharacterProperties -> String
    show :: TextCharacterProperties -> String
    $cshowList :: [TextCharacterProperties] -> ShowS
    showList :: [TextCharacterProperties] -> ShowS
    Show, (forall x.
     TextCharacterProperties -> Rep TextCharacterProperties x)
    -> (forall x.
        Rep TextCharacterProperties x -> TextCharacterProperties)
    -> Generic TextCharacterProperties
    forall x. Rep TextCharacterProperties x -> TextCharacterProperties
    forall x. TextCharacterProperties -> Rep TextCharacterProperties x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextCharacterProperties -> Rep TextCharacterProperties x
    from :: forall x. TextCharacterProperties -> Rep TextCharacterProperties x
    $cto :: forall x. Rep TextCharacterProperties x -> TextCharacterProperties
    to :: forall x. Rep TextCharacterProperties x -> TextCharacterProperties
    Generic)
    instance NFData TextCharacterProperties

    -- | Text run
    --
    -- TODO: br, fld
    data TextRun = RegularRun
      { TextRun -> Maybe TextCharacterProperties
    _txrCharProps :: Maybe TextCharacterProperties
      , TextRun -> Text
    _txrText :: Text
      } deriving (TextRun -> TextRun -> Bool
    (TextRun -> TextRun -> Bool)
    -> (TextRun -> TextRun -> Bool) -> Eq TextRun
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TextRun -> TextRun -> Bool
    == :: TextRun -> TextRun -> Bool
    $c/= :: TextRun -> TextRun -> Bool
    /= :: TextRun -> TextRun -> Bool
    Eq, Int -> TextRun -> ShowS
    [TextRun] -> ShowS
    TextRun -> String
    (Int -> TextRun -> ShowS)
    -> (TextRun -> String) -> ([TextRun] -> ShowS) -> Show TextRun
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TextRun -> ShowS
    showsPrec :: Int -> TextRun -> ShowS
    $cshow :: TextRun -> String
    show :: TextRun -> String
    $cshowList :: [TextRun] -> ShowS
    showList :: [TextRun] -> ShowS
    Show, (forall x. TextRun -> Rep TextRun x)
    -> (forall x. Rep TextRun x -> TextRun) -> Generic TextRun
    forall x. Rep TextRun x -> TextRun
    forall x. TextRun -> Rep TextRun x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. TextRun -> Rep TextRun x
    from :: forall x. TextRun -> Rep TextRun x
    $cto :: forall x. Rep TextRun x -> TextRun
    to :: forall x. Rep TextRun x -> TextRun
    Generic)
    instance NFData TextRun

    -- | This simple type represents a one dimensional position or length
    --
    -- See 20.1.10.16 "ST_Coordinate (Coordinate)" (p. 2921)
    data Coordinate
      = UnqCoordinate Int
        -- ^ see 20.1.10.19 "ST_CoordinateUnqualified (Coordinate)" (p. 2922)
      | UniversalMeasure UnitIdentifier
                         Double
        -- ^ see 22.9.2.15 "ST_UniversalMeasure (Universal Measurement)" (p. 3793)
      deriving (Coordinate -> Coordinate -> Bool
    (Coordinate -> Coordinate -> Bool)
    -> (Coordinate -> Coordinate -> Bool) -> Eq Coordinate
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Coordinate -> Coordinate -> Bool
    == :: Coordinate -> Coordinate -> Bool
    $c/= :: Coordinate -> Coordinate -> Bool
    /= :: Coordinate -> Coordinate -> Bool
    Eq, Int -> Coordinate -> ShowS
    [Coordinate] -> ShowS
    Coordinate -> String
    (Int -> Coordinate -> ShowS)
    -> (Coordinate -> String)
    -> ([Coordinate] -> ShowS)
    -> Show Coordinate
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Coordinate -> ShowS
    showsPrec :: Int -> Coordinate -> ShowS
    $cshow :: Coordinate -> String
    show :: Coordinate -> String
    $cshowList :: [Coordinate] -> ShowS
    showList :: [Coordinate] -> ShowS
    Show, (forall x. Coordinate -> Rep Coordinate x)
    -> (forall x. Rep Coordinate x -> Coordinate) -> Generic Coordinate
    forall x. Rep Coordinate x -> Coordinate
    forall x. Coordinate -> Rep Coordinate x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Coordinate -> Rep Coordinate x
    from :: forall x. Coordinate -> Rep Coordinate x
    $cto :: forall x. Rep Coordinate x -> Coordinate
    to :: forall x. Rep Coordinate x -> Coordinate
    Generic)
    instance NFData Coordinate

    -- | Units used in "Universal measure" coordinates
    -- see 22.9.2.15 "ST_UniversalMeasure (Universal Measurement)" (p. 3793)
    data UnitIdentifier
      = UnitCm -- "cm" As defined in ISO 31.
      | UnitMm -- "mm" As defined in ISO 31.
      | UnitIn -- "in" 1 in = 2.54 cm (informative)
      | UnitPt -- "pt" 1 pt = 1/72 in (informative)
      | UnitPc -- "pc" 1 pc = 12 pt (informative)
      | UnitPi -- "pi" 1 pi = 12 pt (informative)
      deriving (UnitIdentifier -> UnitIdentifier -> Bool
    (UnitIdentifier -> UnitIdentifier -> Bool)
    -> (UnitIdentifier -> UnitIdentifier -> Bool) -> Eq UnitIdentifier
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: UnitIdentifier -> UnitIdentifier -> Bool
    == :: UnitIdentifier -> UnitIdentifier -> Bool
    $c/= :: UnitIdentifier -> UnitIdentifier -> Bool
    /= :: UnitIdentifier -> UnitIdentifier -> Bool
    Eq, Int -> UnitIdentifier -> ShowS
    [UnitIdentifier] -> ShowS
    UnitIdentifier -> String
    (Int -> UnitIdentifier -> ShowS)
    -> (UnitIdentifier -> String)
    -> ([UnitIdentifier] -> ShowS)
    -> Show UnitIdentifier
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> UnitIdentifier -> ShowS
    showsPrec :: Int -> UnitIdentifier -> ShowS
    $cshow :: UnitIdentifier -> String
    show :: UnitIdentifier -> String
    $cshowList :: [UnitIdentifier] -> ShowS
    showList :: [UnitIdentifier] -> ShowS
    Show, (forall x. UnitIdentifier -> Rep UnitIdentifier x)
    -> (forall x. Rep UnitIdentifier x -> UnitIdentifier)
    -> Generic UnitIdentifier
    forall x. Rep UnitIdentifier x -> UnitIdentifier
    forall x. UnitIdentifier -> Rep UnitIdentifier x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. UnitIdentifier -> Rep UnitIdentifier x
    from :: forall x. UnitIdentifier -> Rep UnitIdentifier x
    $cto :: forall x. Rep UnitIdentifier x -> UnitIdentifier
    to :: forall x. Rep UnitIdentifier x -> UnitIdentifier
    Generic)
    instance NFData UnitIdentifier

    -- See @CT_Point2D@ (p. 3989)
    data Point2D = Point2D
      { Point2D -> Coordinate
    _pt2dX :: Coordinate
      , Point2D -> Coordinate
    _pt2dY :: Coordinate
      } deriving (Point2D -> Point2D -> Bool
    (Point2D -> Point2D -> Bool)
    -> (Point2D -> Point2D -> Bool) -> Eq Point2D
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Point2D -> Point2D -> Bool
    == :: Point2D -> Point2D -> Bool
    $c/= :: Point2D -> Point2D -> Bool
    /= :: Point2D -> Point2D -> Bool
    Eq, Int -> Point2D -> ShowS
    [Point2D] -> ShowS
    Point2D -> String
    (Int -> Point2D -> ShowS)
    -> (Point2D -> String) -> ([Point2D] -> ShowS) -> Show Point2D
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Point2D -> ShowS
    showsPrec :: Int -> Point2D -> ShowS
    $cshow :: Point2D -> String
    show :: Point2D -> String
    $cshowList :: [Point2D] -> ShowS
    showList :: [Point2D] -> ShowS
    Show, (forall x. Point2D -> Rep Point2D x)
    -> (forall x. Rep Point2D x -> Point2D) -> Generic Point2D
    forall x. Rep Point2D x -> Point2D
    forall x. Point2D -> Rep Point2D x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Point2D -> Rep Point2D x
    from :: forall x. Point2D -> Rep Point2D x
    $cto :: forall x. Rep Point2D x -> Point2D
    to :: forall x. Rep Point2D x -> Point2D
    Generic)
    instance NFData Point2D

    unqPoint2D :: Int -> Int -> Point2D
    unqPoint2D :: Int -> Int -> Point2D
    unqPoint2D Int
    x Int
    y = Coordinate -> Coordinate -> Point2D
    Point2D (Int -> Coordinate
    UnqCoordinate Int
    x) (Int -> Coordinate
    UnqCoordinate Int
    y)

    -- | Positive position or length in EMUs, maximu allowed value is 27273042316900.
    -- see 20.1.10.41 "ST_PositiveCoordinate (Positive Coordinate)" (p. 2942)
    newtype PositiveCoordinate =
      PositiveCoordinate Integer
      deriving (PositiveCoordinate -> PositiveCoordinate -> Bool
    (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> Eq PositiveCoordinate
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PositiveCoordinate -> PositiveCoordinate -> Bool
    == :: PositiveCoordinate -> PositiveCoordinate -> Bool
    $c/= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    /= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    Eq, Eq PositiveCoordinate
    Eq PositiveCoordinate =>
    (PositiveCoordinate -> PositiveCoordinate -> Ordering)
    -> (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> (PositiveCoordinate -> PositiveCoordinate -> Bool)
    -> (PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate)
    -> (PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate)
    -> Ord PositiveCoordinate
    PositiveCoordinate -> PositiveCoordinate -> Bool
    PositiveCoordinate -> PositiveCoordinate -> Ordering
    PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: PositiveCoordinate -> PositiveCoordinate -> Ordering
    compare :: PositiveCoordinate -> PositiveCoordinate -> Ordering
    $c< :: PositiveCoordinate -> PositiveCoordinate -> Bool
    < :: PositiveCoordinate -> PositiveCoordinate -> Bool
    $c<= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    <= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    $c> :: PositiveCoordinate -> PositiveCoordinate -> Bool
    > :: PositiveCoordinate -> PositiveCoordinate -> Bool
    $c>= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    >= :: PositiveCoordinate -> PositiveCoordinate -> Bool
    $cmax :: PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate
    max :: PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate
    $cmin :: PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate
    min :: PositiveCoordinate -> PositiveCoordinate -> PositiveCoordinate
    Ord, Int -> PositiveCoordinate -> ShowS
    [PositiveCoordinate] -> ShowS
    PositiveCoordinate -> String
    (Int -> PositiveCoordinate -> ShowS)
    -> (PositiveCoordinate -> String)
    -> ([PositiveCoordinate] -> ShowS)
    -> Show PositiveCoordinate
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PositiveCoordinate -> ShowS
    showsPrec :: Int -> PositiveCoordinate -> ShowS
    $cshow :: PositiveCoordinate -> String
    show :: PositiveCoordinate -> String
    $cshowList :: [PositiveCoordinate] -> ShowS
    showList :: [PositiveCoordinate] -> ShowS
    Show, (forall x. PositiveCoordinate -> Rep PositiveCoordinate x)
    -> (forall x. Rep PositiveCoordinate x -> PositiveCoordinate)
    -> Generic PositiveCoordinate
    forall x. Rep PositiveCoordinate x -> PositiveCoordinate
    forall x. PositiveCoordinate -> Rep PositiveCoordinate x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. PositiveCoordinate -> Rep PositiveCoordinate x
    from :: forall x. PositiveCoordinate -> Rep PositiveCoordinate x
    $cto :: forall x. Rep PositiveCoordinate x -> PositiveCoordinate
    to :: forall x. Rep PositiveCoordinate x -> PositiveCoordinate
    Generic)
    instance NFData PositiveCoordinate

    data PositiveSize2D = PositiveSize2D
      { PositiveSize2D -> PositiveCoordinate
    _ps2dX :: PositiveCoordinate
      , PositiveSize2D -> PositiveCoordinate
    _ps2dY :: PositiveCoordinate
      } deriving (PositiveSize2D -> PositiveSize2D -> Bool
    (PositiveSize2D -> PositiveSize2D -> Bool)
    -> (PositiveSize2D -> PositiveSize2D -> Bool) -> Eq PositiveSize2D
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PositiveSize2D -> PositiveSize2D -> Bool
    == :: PositiveSize2D -> PositiveSize2D -> Bool
    $c/= :: PositiveSize2D -> PositiveSize2D -> Bool
    /= :: PositiveSize2D -> PositiveSize2D -> Bool
    Eq, Int -> PositiveSize2D -> ShowS
    [PositiveSize2D] -> ShowS
    PositiveSize2D -> String
    (Int -> PositiveSize2D -> ShowS)
    -> (PositiveSize2D -> String)
    -> ([PositiveSize2D] -> ShowS)
    -> Show PositiveSize2D
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PositiveSize2D -> ShowS
    showsPrec :: Int -> PositiveSize2D -> ShowS
    $cshow :: PositiveSize2D -> String
    show :: PositiveSize2D -> String
    $cshowList :: [PositiveSize2D] -> ShowS
    showList :: [PositiveSize2D] -> ShowS
    Show, (forall x. PositiveSize2D -> Rep PositiveSize2D x)
    -> (forall x. Rep PositiveSize2D x -> PositiveSize2D)
    -> Generic PositiveSize2D
    forall x. Rep PositiveSize2D x -> PositiveSize2D
    forall x. PositiveSize2D -> Rep PositiveSize2D x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. PositiveSize2D -> Rep PositiveSize2D x
    from :: forall x. PositiveSize2D -> Rep PositiveSize2D x
    $cto :: forall x. Rep PositiveSize2D x -> PositiveSize2D
    to :: forall x. Rep PositiveSize2D x -> PositiveSize2D
    Generic)
    instance NFData PositiveSize2D

    positiveSize2D :: Integer -> Integer -> PositiveSize2D
    positiveSize2D :: Integer -> Integer -> PositiveSize2D
    positiveSize2D Integer
    x Integer
    y =
      PositiveCoordinate -> PositiveCoordinate -> PositiveSize2D
    PositiveSize2D (Integer -> PositiveCoordinate
    PositiveCoordinate Integer
    x) (Integer -> PositiveCoordinate
    PositiveCoordinate Integer
    y)

    cmSize2D :: Integer -> Integer -> PositiveSize2D
    cmSize2D :: Integer -> Integer -> PositiveSize2D
    cmSize2D Integer
    x Integer
    y = Integer -> Integer -> PositiveSize2D
    positiveSize2D (Integer -> Integer
    cm2emu Integer
    x) (Integer -> Integer
    cm2emu Integer
    y)

    cm2emu :: Integer -> Integer
    cm2emu :: Integer -> Integer
    cm2emu Integer
    cm = Integer
    360000 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    * Integer
    cm

    -- See 20.1.7.6 "xfrm (2D Transform for Individual Objects)" (p. 2849)
    data Transform2D = Transform2D
      { Transform2D -> Angle
    _trRot :: Angle
        -- ^ Specifies the rotation of the Graphic Frame.
      , Transform2D -> Bool
    _trFlipH :: Bool
        -- ^ Specifies a horizontal flip. When true, this attribute defines
        -- that the shape is flipped horizontally about the center of its bounding box.
      , Transform2D -> Bool
    _trFlipV :: Bool
        -- ^ Specifies a vertical flip. When true, this attribute defines
        -- that the shape is flipped vetically about the center of its bounding box.
      , Transform2D -> Maybe Point2D
    _trOffset :: Maybe Point2D
        -- ^ See 20.1.7.4 "off (Offset)" (p. 2847)
      , Transform2D -> Maybe PositiveSize2D
    _trExtents :: Maybe PositiveSize2D
        -- ^ See 20.1.7.3 "ext (Extents)" (p. 2846) or
        -- 20.5.2.14 "ext (Shape Extent)" (p. 3165)
      } deriving (Transform2D -> Transform2D -> Bool
    (Transform2D -> Transform2D -> Bool)
    -> (Transform2D -> Transform2D -> Bool) -> Eq Transform2D
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Transform2D -> Transform2D -> Bool
    == :: Transform2D -> Transform2D -> Bool
    $c/= :: Transform2D -> Transform2D -> Bool
    /= :: Transform2D -> Transform2D -> Bool
    Eq, Int -> Transform2D -> ShowS
    [Transform2D] -> ShowS
    Transform2D -> String
    (Int -> Transform2D -> ShowS)
    -> (Transform2D -> String)
    -> ([Transform2D] -> ShowS)
    -> Show Transform2D
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Transform2D -> ShowS
    showsPrec :: Int -> Transform2D -> ShowS
    $cshow :: Transform2D -> String
    show :: Transform2D -> String
    $cshowList :: [Transform2D] -> ShowS
    showList :: [Transform2D] -> ShowS
    Show, (forall x. Transform2D -> Rep Transform2D x)
    -> (forall x. Rep Transform2D x -> Transform2D)
    -> Generic Transform2D
    forall x. Rep Transform2D x -> Transform2D
    forall x. Transform2D -> Rep Transform2D x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Transform2D -> Rep Transform2D x
    from :: forall x. Transform2D -> Rep Transform2D x
    $cto :: forall x. Rep Transform2D x -> Transform2D
    to :: forall x. Rep Transform2D x -> Transform2D
    Generic)
    instance NFData Transform2D

    -- TODO: custGeom
    data Geometry =
      PresetGeometry
      -- TODO: prst, avList
      -- currently uses "rect" with empty avList
      deriving (Geometry -> Geometry -> Bool
    (Geometry -> Geometry -> Bool)
    -> (Geometry -> Geometry -> Bool) -> Eq Geometry
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Geometry -> Geometry -> Bool
    == :: Geometry -> Geometry -> Bool
    $c/= :: Geometry -> Geometry -> Bool
    /= :: Geometry -> Geometry -> Bool
    Eq, Int -> Geometry -> ShowS
    [Geometry] -> ShowS
    Geometry -> String
    (Int -> Geometry -> ShowS)
    -> (Geometry -> String) -> ([Geometry] -> ShowS) -> Show Geometry
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Geometry -> ShowS
    showsPrec :: Int -> Geometry -> ShowS
    $cshow :: Geometry -> String
    show :: Geometry -> String
    $cshowList :: [Geometry] -> ShowS
    showList :: [Geometry] -> ShowS
    Show, (forall x. Geometry -> Rep Geometry x)
    -> (forall x. Rep Geometry x -> Geometry) -> Generic Geometry
    forall x. Rep Geometry x -> Geometry
    forall x. Geometry -> Rep Geometry x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Geometry -> Rep Geometry x
    from :: forall x. Geometry -> Rep Geometry x
    $cto :: forall x. Rep Geometry x -> Geometry
    to :: forall x. Rep Geometry x -> Geometry
    Generic)
    instance NFData Geometry

    -- See 20.1.2.2.35 "spPr (Shape Properties)" (p. 2751)
    data ShapeProperties = ShapeProperties
      { ShapeProperties -> Maybe Transform2D
    _spXfrm :: Maybe Transform2D
      , ShapeProperties -> Maybe Geometry
    _spGeometry :: Maybe Geometry
      , ShapeProperties -> Maybe FillProperties
    _spFill :: Maybe FillProperties
      , ShapeProperties -> Maybe LineProperties
    _spOutline :: Maybe LineProperties
        -- TODO: bwMode, a_EG_EffectProperties, scene3d, sp3d, extLst
      } deriving (ShapeProperties -> ShapeProperties -> Bool
    (ShapeProperties -> ShapeProperties -> Bool)
    -> (ShapeProperties -> ShapeProperties -> Bool)
    -> Eq ShapeProperties
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ShapeProperties -> ShapeProperties -> Bool
    == :: ShapeProperties -> ShapeProperties -> Bool
    $c/= :: ShapeProperties -> ShapeProperties -> Bool
    /= :: ShapeProperties -> ShapeProperties -> Bool
    Eq, Int -> ShapeProperties -> ShowS
    [ShapeProperties] -> ShowS
    ShapeProperties -> String
    (Int -> ShapeProperties -> ShowS)
    -> (ShapeProperties -> String)
    -> ([ShapeProperties] -> ShowS)
    -> Show ShapeProperties
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ShapeProperties -> ShowS
    showsPrec :: Int -> ShapeProperties -> ShowS
    $cshow :: ShapeProperties -> String
    show :: ShapeProperties -> String
    $cshowList :: [ShapeProperties] -> ShowS
    showList :: [ShapeProperties] -> ShowS
    Show, (forall x. ShapeProperties -> Rep ShapeProperties x)
    -> (forall x. Rep ShapeProperties x -> ShapeProperties)
    -> Generic ShapeProperties
    forall x. Rep ShapeProperties x -> ShapeProperties
    forall x. ShapeProperties -> Rep ShapeProperties x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ShapeProperties -> Rep ShapeProperties x
    from :: forall x. ShapeProperties -> Rep ShapeProperties x
    $cto :: forall x. Rep ShapeProperties x -> ShapeProperties
    to :: forall x. Rep ShapeProperties x -> ShapeProperties
    Generic)
    instance NFData ShapeProperties

    -- | Specifies an outline style that can be applied to a number of
    -- different objects such as shapes and text.
    --
    -- TODO: cap, cmpd, algn, a_EG_LineDashProperties,
    --   a_EG_LineJoinProperties, headEnd, tailEnd, extLst
    --
    -- See 20.1.2.2.24 "ln (Outline)" (p. 2744)
    data LineProperties = LineProperties
      { LineProperties -> Maybe FillProperties
    _lnFill :: Maybe FillProperties
      , LineProperties -> Int
    _lnWidth :: Int
      -- ^ Specifies the width to be used for the underline stroke.  The
      -- value is in EMU, is greater of equal to 0 and maximum value is
      -- 20116800.
      } deriving (LineProperties -> LineProperties -> Bool
    (LineProperties -> LineProperties -> Bool)
    -> (LineProperties -> LineProperties -> Bool) -> Eq LineProperties
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: LineProperties -> LineProperties -> Bool
    == :: LineProperties -> LineProperties -> Bool
    $c/= :: LineProperties -> LineProperties -> Bool
    /= :: LineProperties -> LineProperties -> Bool
    Eq, Int -> LineProperties -> ShowS
    [LineProperties] -> ShowS
    LineProperties -> String
    (Int -> LineProperties -> ShowS)
    -> (LineProperties -> String)
    -> ([LineProperties] -> ShowS)
    -> Show LineProperties
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> LineProperties -> ShowS
    showsPrec :: Int -> LineProperties -> ShowS
    $cshow :: LineProperties -> String
    show :: LineProperties -> String
    $cshowList :: [LineProperties] -> ShowS
    showList :: [LineProperties] -> ShowS
    Show, (forall x. LineProperties -> Rep LineProperties x)
    -> (forall x. Rep LineProperties x -> LineProperties)
    -> Generic LineProperties
    forall x. Rep LineProperties x -> LineProperties
    forall x. LineProperties -> Rep LineProperties x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. LineProperties -> Rep LineProperties x
    from :: forall x. LineProperties -> Rep LineProperties x
    $cto :: forall x. Rep LineProperties x -> LineProperties
    to :: forall x. Rep LineProperties x -> LineProperties
    Generic)
    instance NFData LineProperties

    -- | Color choice for some drawing element
    --
    -- TODO: scrgbClr, hslClr, sysClr, schemeClr, prstClr
    --
    -- See @EG_ColorChoice@ (p. 3996)
    data ColorChoice =
      RgbColor Text
      -- ^ Specifies a color using the red, green, blue RGB color
      -- model. Red, green, and blue is expressed as sequence of hex
      -- digits, RRGGBB. A perceptual gamma of 2.2 is used.
      --
      -- See 20.1.2.3.32 "srgbClr (RGB Color Model - Hex Variant)" (p. 2773)
      deriving (ColorChoice -> ColorChoice -> Bool
    (ColorChoice -> ColorChoice -> Bool)
    -> (ColorChoice -> ColorChoice -> Bool) -> Eq ColorChoice
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ColorChoice -> ColorChoice -> Bool
    == :: ColorChoice -> ColorChoice -> Bool
    $c/= :: ColorChoice -> ColorChoice -> Bool
    /= :: ColorChoice -> ColorChoice -> Bool
    Eq, Int -> ColorChoice -> ShowS
    [ColorChoice] -> ShowS
    ColorChoice -> String
    (Int -> ColorChoice -> ShowS)
    -> (ColorChoice -> String)
    -> ([ColorChoice] -> ShowS)
    -> Show ColorChoice
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ColorChoice -> ShowS
    showsPrec :: Int -> ColorChoice -> ShowS
    $cshow :: ColorChoice -> String
    show :: ColorChoice -> String
    $cshowList :: [ColorChoice] -> ShowS
    showList :: [ColorChoice] -> ShowS
    Show, (forall x. ColorChoice -> Rep ColorChoice x)
    -> (forall x. Rep ColorChoice x -> ColorChoice)
    -> Generic ColorChoice
    forall x. Rep ColorChoice x -> ColorChoice
    forall x. ColorChoice -> Rep ColorChoice x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ColorChoice -> Rep ColorChoice x
    from :: forall x. ColorChoice -> Rep ColorChoice x
    $cto :: forall x. Rep ColorChoice x -> ColorChoice
    to :: forall x. Rep ColorChoice x -> ColorChoice
    Generic)
    instance NFData ColorChoice

    -- TODO: gradFill, pattFill
    data FillProperties =
      NoFill
      -- ^ See 20.1.8.44 "noFill (No Fill)" (p. 2872)
      | SolidFill (Maybe ColorChoice)
      -- ^ Solid fill
      -- See 20.1.8.54 "solidFill (Solid Fill)" (p. 2879)
      deriving (FillProperties -> FillProperties -> Bool
    (FillProperties -> FillProperties -> Bool)
    -> (FillProperties -> FillProperties -> Bool) -> Eq FillProperties
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: FillProperties -> FillProperties -> Bool
    == :: FillProperties -> FillProperties -> Bool
    $c/= :: FillProperties -> FillProperties -> Bool
    /= :: FillProperties -> FillProperties -> Bool
    Eq, Int -> FillProperties -> ShowS
    [FillProperties] -> ShowS
    FillProperties -> String
    (Int -> FillProperties -> ShowS)
    -> (FillProperties -> String)
    -> ([FillProperties] -> ShowS)
    -> Show FillProperties
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> FillProperties -> ShowS
    showsPrec :: Int -> FillProperties -> ShowS
    $cshow :: FillProperties -> String
    show :: FillProperties -> String
    $cshowList :: [FillProperties] -> ShowS
    showList :: [FillProperties] -> ShowS
    Show, (forall x. FillProperties -> Rep FillProperties x)
    -> (forall x. Rep FillProperties x -> FillProperties)
    -> Generic FillProperties
    forall x. Rep FillProperties x -> FillProperties
    forall x. FillProperties -> Rep FillProperties x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. FillProperties -> Rep FillProperties x
    from :: forall x. FillProperties -> Rep FillProperties x
    $cto :: forall x. Rep FillProperties x -> FillProperties
    to :: forall x. Rep FillProperties x -> FillProperties
    Generic)
    instance NFData FillProperties

    -- | solid fill with color specified by hexadecimal RGB color
    solidRgb :: Text -> FillProperties
    solidRgb :: Text -> FillProperties
    solidRgb Text
    t = Maybe ColorChoice -> FillProperties
    SolidFill (Maybe ColorChoice -> FillProperties)
    -> (ColorChoice -> Maybe ColorChoice)
    -> ColorChoice
    -> FillProperties
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ColorChoice -> Maybe ColorChoice
    forall a. a -> Maybe a
    Just (ColorChoice -> FillProperties) -> ColorChoice -> FillProperties
    forall a b. (a -> b) -> a -> b
    $ Text -> ColorChoice
    RgbColor Text
    t

    makeLenses ''ShapeProperties

    {-------------------------------------------------------------------------------
      Default instances
    -------------------------------------------------------------------------------}

    instance Default ShapeProperties where
        def :: ShapeProperties
    def = Maybe Transform2D
    -> Maybe Geometry
    -> Maybe FillProperties
    -> Maybe LineProperties
    -> ShapeProperties
    ShapeProperties Maybe Transform2D
    forall a. Maybe a
    Nothing Maybe Geometry
    forall a. Maybe a
    Nothing Maybe FillProperties
    forall a. Maybe a
    Nothing Maybe LineProperties
    forall a. Maybe a
    Nothing

    instance Default LineProperties where
      def :: LineProperties
    def = Maybe FillProperties -> Int -> LineProperties
    LineProperties Maybe FillProperties
    forall a. Maybe a
    Nothing Int
    0

    {-------------------------------------------------------------------------------
      Parsing
    -------------------------------------------------------------------------------}

    instance FromCursor TextBody where
      fromCursor :: Cursor -> [TextBody]
    fromCursor Cursor
    cur = do
        cur' <- Cursor
    cur Cursor -> (Cursor -> [Cursor]) -> [Cursor]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Cursor -> [Cursor]
    element (Text -> Name
    a_ Text
    "bodyPr")
        _txbdRotation <- fromAttributeDef "rot" (Angle 0) cur'
        _txbdSpcFirstLastPara <- fromAttributeDef "spcFirstLastPara" False cur'
        _txbdVertOverflow <- fromAttributeDef "vertOverflow" TextVertOverflow cur'
        _txbdVertical <- fromAttributeDef "vert" TextVerticalHorz cur'
        _txbdWrap <- fromAttributeDef "wrap" TextWrapSquare cur'
        _txbdAnchor <- fromAttributeDef "anchor" TextAnchoringTop cur'
        _txbdAnchorCenter <- fromAttributeDef "anchorCtr" False cur'
        let _txbdParagraphs = Cursor
    cur Cursor -> (Cursor -> [TextParagraph]) -> [TextParagraph]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Cursor -> [Cursor]
    element (Text -> Name
    a_ Text
    "p") (Cursor -> [Cursor])
    -> (Cursor -> [TextParagraph]) -> Cursor -> [TextParagraph]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Cursor -> [TextParagraph]
    forall a. FromCursor a => Cursor -> [a]
    fromCursor
        return TextBody {..}

    instance FromCursor TextParagraph where
      fromCursor :: Cursor -> [TextParagraph]
    fromCursor Cursor
    cur = do
        let _txpaDefCharProps :: Maybe TextCharacterProperties
    _txpaDefCharProps =
              Maybe (Maybe TextCharacterProperties)
    -> Maybe TextCharacterProperties
    forall (m :: * -> *) a. Monad m => m (m a) -> m a
    join (Maybe (Maybe TextCharacterProperties)
     -> Maybe TextCharacterProperties)
    -> ([Maybe TextCharacterProperties]
        -> Maybe (Maybe TextCharacterProperties))
    -> [Maybe TextCharacterProperties]
    -> Maybe TextCharacterProperties
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Maybe TextCharacterProperties]
    -> Maybe (Maybe TextCharacterProperties)
    forall a. [a] -> Maybe a
    listToMaybe ([Maybe TextCharacterProperties] -> Maybe TextCharacterProperties)
    -> [Maybe TextCharacterProperties] -> Maybe TextCharacterProperties
    forall a b. (a -> b) -> a -> b
    $
              Cursor
    cur Cursor
    -> (Cursor -> [Maybe TextCharacterProperties])
    -> [Maybe TextCharacterProperties]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Cursor -> [Cursor]
    element (Text -> Name
    a_ Text
    "pPr") (Cursor -> [Cursor])
    -> (Cursor -> [Maybe TextCharacterProperties])
    -> Cursor
    -> [Maybe TextCharacterProperties]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Name -> Cursor -> [Maybe TextCharacterProperties]
    forall a. FromCursor a => Name -> Cursor -> [Maybe a]
    maybeFromElement (Text -> Name
    a_ Text
    "defRPr")
            _txpaRuns :: [TextRun]
    _txpaRuns = Cursor
    cur Cursor -> (Cursor -> [TextRun]) -> [TextRun]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Name -> Cursor -> [Cursor]
    element (Text -> Name
    a_ Text
    "r") (Cursor -> [Cursor])
    -> (Cursor -> [TextRun]) -> Cursor -> [TextRun]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Cursor -> [TextRun]
    forall a. FromCursor a => Cursor -> [a]
    fromCursor
        TextParagraph -> [TextParagraph]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return TextParagraph {[TextRun]
    Maybe TextCharacterProperties
    _txpaDefCharProps :: Maybe TextCharacterProperties
    _txpaRuns :: [TextRun]
    _txpaDefCharProps :: Maybe TextCharacterProperties
    _txpaRuns :: [TextRun]
    ..}

    instance FromCursor TextCharacterProperties where
      fromCursor :: Cursor -> [TextCharacterProperties]
    fromCursor Cursor
    cur = do
        _txchBold <- Name -> Bool -> Cursor -> [Bool]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "b" Bool
    False Cursor
    cur
        _txchItalic <- fromAttributeDef "i" False cur
        _txchUnderline <- fromAttributeDef "u" False cur
        return TextCharacterProperties {..}

    instance FromCursor TextRun where
      fromCursor :: Cursor -> [TextRun]
    fromCursor Cursor
    cur = do
        _txrCharProps <- Name -> Cursor -> [Maybe TextCharacterProperties]
    forall a. FromCursor a => Name -> Cursor -> [Maybe a]
    maybeFromElement (Text -> Name
    a_ Text
    "rPr") Cursor
    cur
        _txrText <- cur $/ element (a_ "t") &/ content
        return RegularRun {..}

    -- See 20.1.10.3 "ST_Angle (Angle)" (p. 2912)
    instance FromAttrVal Angle where
      fromAttrVal :: Reader Angle
    fromAttrVal Text
    t = (Int -> Angle) -> (Int, Text) -> (Angle, Text)
    forall b c d. (b -> c) -> (b, d) -> (c, d)
    forall (a :: * -> * -> *) b c d.
    Arrow a =>
    a b c -> a (b, d) (c, d)
    first Int -> Angle
    Angle ((Int, Text) -> (Angle, Text))
    -> Either String (Int, Text) -> Either String (Angle, Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Reader Int
    forall a. FromAttrVal a => Reader a
    fromAttrVal Text
    t

    -- See 20.1.10.83 "ST_TextVertOverflowType (Text Vertical Overflow)" (p. 3083)
    instance FromAttrVal TextVertOverflow where
      fromAttrVal :: Reader TextVertOverflow
    fromAttrVal Text
    "overflow" = TextVertOverflow -> Either String (TextVertOverflow, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertOverflow
    TextVertOverflow
      fromAttrVal Text
    "ellipsis" = TextVertOverflow -> Either String (TextVertOverflow, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertOverflow
    TextVertOverflowEllipsis
      fromAttrVal Text
    "clip" = TextVertOverflow -> Either String (TextVertOverflow, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertOverflow
    TextVertOverflowClip
      fromAttrVal Text
    t = Text -> Reader TextVertOverflow
    forall a. Text -> Text -> Either String (a, Text)
    invalidText Text
    "TextVertOverflow" Text
    t

    instance FromAttrVal TextVertical where
      fromAttrVal :: Reader TextVertical
    fromAttrVal Text
    "horz" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVerticalHorz
      fromAttrVal Text
    "vert" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVertical
      fromAttrVal Text
    "vert270" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVertical270
      fromAttrVal Text
    "wordArtVert" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVerticalWordArt
      fromAttrVal Text
    "eaVert" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVerticalEA
      fromAttrVal Text
    "mongolianVert" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVerticalMongolian
      fromAttrVal Text
    "wordArtVertRtl" = TextVertical -> Either String (TextVertical, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextVertical
    TextVerticalWordArtRtl
      fromAttrVal Text
    t = Text -> Reader TextVertical
    forall a. Text -> Text -> Either String (a, Text)
    invalidText Text
    "TextVertical" Text
    t

    instance FromAttrVal TextWrap where
      fromAttrVal :: Reader TextWrap
    fromAttrVal Text
    "none" = TextWrap -> Either String (TextWrap, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextWrap
    TextWrapNone
      fromAttrVal Text
    "square" = TextWrap -> Either String (TextWrap, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextWrap
    TextWrapSquare
      fromAttrVal Text
    t = Text -> Reader TextWrap
    forall a. Text -> Text -> Either String (a, Text)
    invalidText Text
    "TextWrap" Text
    t

    -- See 20.1.10.59 "ST_TextAnchoringType (Text Anchoring Types)" (p. 3058)
    instance FromAttrVal TextAnchoring where
      fromAttrVal :: Reader TextAnchoring
    fromAttrVal Text
    "t" = TextAnchoring -> Either String (TextAnchoring, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextAnchoring
    TextAnchoringTop
      fromAttrVal Text
    "ctr" = TextAnchoring -> Either String (TextAnchoring, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextAnchoring
    TextAnchoringCenter
      fromAttrVal Text
    "b" = TextAnchoring -> Either String (TextAnchoring, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextAnchoring
    TextAnchoringBottom
      fromAttrVal Text
    "just" = TextAnchoring -> Either String (TextAnchoring, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextAnchoring
    TextAnchoringJustified
      fromAttrVal Text
    "dist" = TextAnchoring -> Either String (TextAnchoring, Text)
    forall a. a -> Either String (a, Text)
    readSuccess TextAnchoring
    TextAnchoringDistributed
      fromAttrVal Text
    t = Text -> Reader TextAnchoring
    forall a. Text -> Text -> Either String (a, Text)
    invalidText Text
    "TextAnchoring" Text
    t

    instance FromCursor ShapeProperties where
      fromCursor :: Cursor -> [ShapeProperties]
    fromCursor Cursor
    cur = do
        _spXfrm <- Name -> Cursor -> [Maybe Transform2D]
    forall a. FromCursor a => Name -> Cursor -> [Maybe a]
    maybeFromElement (Text -> Name
    a_ Text
    "xfrm") Cursor
    cur
        let _spGeometry = [Geometry] -> Maybe Geometry
    forall a. [a] -> Maybe a
    listToMaybe ([Geometry] -> Maybe Geometry) -> [Geometry] -> Maybe Geometry
    forall a b. (a -> b) -> a -> b
    $ Cursor
    cur Cursor -> (Cursor -> [Geometry]) -> [Geometry]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Cursor -> [Cursor]
    anyElement (Cursor -> [Cursor])
    -> (Cursor -> [Geometry]) -> Cursor -> [Geometry]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Cursor -> [Geometry]
    forall a. FromCursor a => Cursor -> [a]
    fromCursor
            _spFill = [FillProperties] -> Maybe FillProperties
    forall a. [a] -> Maybe a
    listToMaybe ([FillProperties] -> Maybe FillProperties)
    -> [FillProperties] -> Maybe FillProperties
    forall a b. (a -> b) -> a -> b
    $ Cursor
    cur Cursor -> (Cursor -> [FillProperties]) -> [FillProperties]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Cursor -> [Cursor]
    anyElement (Cursor -> [Cursor])
    -> (Cursor -> [FillProperties]) -> Cursor -> [FillProperties]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Node -> [FillProperties]
    fillPropsFromNode (Node -> [FillProperties])
    -> (Cursor -> Node) -> Cursor -> [FillProperties]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Cursor -> Node
    forall node. Cursor node -> node
    node
        _spOutline <- maybeFromElement (a_ "ln") cur
        return ShapeProperties {..}

    instance FromCursor Transform2D where
        fromCursor :: Cursor -> [Transform2D]
    fromCursor Cursor
    cur = do
            _trRot     <- Name -> Angle -> Cursor -> [Angle]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "rot" (Int -> Angle
    Angle Int
    0) Cursor
    cur
            _trFlipH   <- fromAttributeDef "flipH" False cur
            _trFlipV   <- fromAttributeDef "flipV" False cur
            _trOffset  <- maybeFromElement (a_ "off") cur
            _trExtents <- maybeFromElement (a_ "ext") cur
            return Transform2D{..}

    instance FromCursor Geometry where
        fromCursor :: Cursor -> [Geometry]
    fromCursor = Node -> [Geometry]
    geometryFromNode (Node -> [Geometry]) -> (Cursor -> Node) -> Cursor -> [Geometry]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Cursor -> Node
    forall node. Cursor node -> node
    node

    geometryFromNode :: Node -> [Geometry]
    geometryFromNode :: Node -> [Geometry]
    geometryFromNode Node
    n | Node
    n Node -> Name -> Bool
    `nodeElNameIs` Text -> Name
    a_ Text
    "prstGeom" =
                             Geometry -> [Geometry]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return Geometry
    PresetGeometry
                       | Bool
    otherwise = String -> [Geometry]
    forall a. String -> [a]
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "no matching geometry node"

    instance FromCursor LineProperties where
        fromCursor :: Cursor -> [LineProperties]
    fromCursor Cursor
    cur = do
            let _lnFill :: Maybe FillProperties
    _lnFill = [FillProperties] -> Maybe FillProperties
    forall a. [a] -> Maybe a
    listToMaybe ([FillProperties] -> Maybe FillProperties)
    -> [FillProperties] -> Maybe FillProperties
    forall a b. (a -> b) -> a -> b
    $ Cursor
    cur Cursor -> (Cursor -> [FillProperties]) -> [FillProperties]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Cursor -> [Cursor]
    anyElement (Cursor -> [Cursor])
    -> (Cursor -> [FillProperties]) -> Cursor -> [FillProperties]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Cursor -> [FillProperties]
    forall a. FromCursor a => Cursor -> [a]
    fromCursor
            _lnWidth <- Name -> Int -> Cursor -> [Int]
    forall a. FromAttrVal a => Name -> a -> Cursor -> [a]
    fromAttributeDef Name
    "w" Int
    0 Cursor
    cur
            return LineProperties{..}

    instance FromCursor Point2D where
        fromCursor :: Cursor -> [Point2D]
    fromCursor Cursor
    cur = do
            x <- Text -> [Coordinate]
    forall (m :: * -> *). MonadFail m => Text -> m Coordinate
    coordinate (Text -> [Coordinate]) -> [Text] -> [Coordinate]
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< Name -> Cursor -> [Text]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "x" Cursor
    cur
            y <- coordinate =<< fromAttribute "y" cur
            return $ Point2D x y

    instance FromCursor PositiveSize2D where
        fromCursor :: Cursor -> [PositiveSize2D]
    fromCursor Cursor
    cur = do
            cx <- Integer -> PositiveCoordinate
    PositiveCoordinate (Integer -> PositiveCoordinate)
    -> [Integer] -> [PositiveCoordinate]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Name -> Cursor -> [Integer]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "cx" Cursor
    cur
            cy <- PositiveCoordinate <$> fromAttribute "cy" cur
            return $ PositiveSize2D cx cy

    instance FromCursor FillProperties where
        fromCursor :: Cursor -> [FillProperties]
    fromCursor = Node -> [FillProperties]
    fillPropsFromNode (Node -> [FillProperties])
    -> (Cursor -> Node) -> Cursor -> [FillProperties]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Cursor -> Node
    forall node. Cursor node -> node
    node

    fillPropsFromNode :: Node -> [FillProperties]
    fillPropsFromNode :: Node -> [FillProperties]
    fillPropsFromNode Node
    n
      | Node
    n Node -> Name -> Bool
    `nodeElNameIs` Text -> Name
    a_ Text
    "noFill" = FillProperties -> [FillProperties]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return FillProperties
    NoFill
      | Node
    n Node -> Name -> Bool
    `nodeElNameIs` Text -> Name
    a_ Text
    "solidFill" = do
        let color :: Maybe ColorChoice
    color =
              [ColorChoice] -> Maybe ColorChoice
    forall a. [a] -> Maybe a
    listToMaybe ([ColorChoice] -> Maybe ColorChoice)
    -> [ColorChoice] -> Maybe ColorChoice
    forall a b. (a -> b) -> a -> b
    $ Node -> Cursor
    fromNode Node
    n Cursor -> (Cursor -> [ColorChoice]) -> [ColorChoice]
    forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
    $/ Cursor -> [Cursor]
    anyElement (Cursor -> [Cursor])
    -> (Cursor -> [ColorChoice]) -> Cursor -> [ColorChoice]
    forall (m :: * -> *) a b c.
    Monad m =>
    (a -> m b) -> (b -> m c) -> a -> m c
    >=> Node -> [ColorChoice]
    colorChoiceFromNode (Node -> [ColorChoice])
    -> (Cursor -> Node) -> Cursor -> [ColorChoice]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Cursor -> Node
    forall node. Cursor node -> node
    node
        FillProperties -> [FillProperties]
    forall a. a -> [a]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (FillProperties -> [FillProperties])
    -> FillProperties -> [FillProperties]
    forall a b. (a -> b) -> a -> b
    $ Maybe ColorChoice -> FillProperties
    SolidFill Maybe ColorChoice
    color
      | Bool
    otherwise = String -> [FillProperties]
    forall a. String -> [a]
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "no matching line fill node"

    colorChoiceFromNode :: Node -> [ColorChoice]
    colorChoiceFromNode :: Node -> [ColorChoice]
    colorChoiceFromNode Node
    n
      | Node
    n Node -> Name -> Bool
    `nodeElNameIs` Text -> Name
    a_ Text
    "srgbClr" = do
        val <- Name -> Cursor -> [Text]
    forall a. FromAttrVal a => Name -> Cursor -> [a]
    fromAttribute Name
    "val" (Cursor -> [Text]) -> Cursor -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Node -> Cursor
    fromNode Node
    n
        return $ RgbColor val
      | Bool
    otherwise = String -> [ColorChoice]
    forall a. String -> [a]
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "no matching color choice node"

    coordinate :: MonadFail m => Text -> m Coordinate
    coordinate :: forall (m :: * -> *). MonadFail m => Text -> m Coordinate
    coordinate Text
    t =  case Reader Int
    forall a. Integral a => Reader a
    T.decimal Text
    t of
      Right (Int
    d, Text
    leftover) | Text
    leftover Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    T.empty ->
          Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ Int -> Coordinate
    UnqCoordinate Int
    d
      Either String (Int, Text)
    _ ->
          case Reader Double
    forall a. Fractional a => Reader a
    T.rational Text
    t of
              Right (Double
    r, Text
    "cm") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitCm Double
    r
              Right (Double
    r, Text
    "mm") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitMm Double
    r
              Right (Double
    r, Text
    "in") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitIn Double
    r
              Right (Double
    r, Text
    "pt") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitPt Double
    r
              Right (Double
    r, Text
    "pc") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitPc Double
    r
              Right (Double
    r, Text
    "pi") -> Coordinate -> m Coordinate
    forall a. a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Coordinate -> m Coordinate) -> Coordinate -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ UnitIdentifier -> Double -> Coordinate
    UniversalMeasure UnitIdentifier
    UnitPi Double
    r
              Either String (Double, Text)
    _               -> String -> m Coordinate
    forall a. String -> m a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> m Coordinate) -> String -> m Coordinate
    forall a b. (a -> b) -> a -> b
    $ String
    "invalid coordinate: " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    forall a. Show a => a -> String
    show Text
    t

    {-------------------------------------------------------------------------------
      Rendering
    -------------------------------------------------------------------------------}

    instance ToElement TextBody where
      toElement :: Name -> TextBody -> Element
    toElement Name
    nm TextBody {Bool
    [TextParagraph]
    TextAnchoring
    TextWrap
    TextVertical
    TextVertOverflow
    Angle
    _txbdRotation :: TextBody -> Angle
    _txbdSpcFirstLastPara :: TextBody -> Bool
    _txbdVertOverflow :: TextBody -> TextVertOverflow
    _txbdVertical :: TextBody -> TextVertical
    _txbdWrap :: TextBody -> TextWrap
    _txbdAnchor :: TextBody -> TextAnchoring
    _txbdAnchorCenter :: TextBody -> Bool
    _txbdParagraphs :: TextBody -> [TextParagraph]
    _txbdRotation :: Angle
    _txbdSpcFirstLastPara :: Bool
    _txbdVertOverflow :: TextVertOverflow
    _txbdVertical :: TextVertical
    _txbdWrap :: TextWrap
    _txbdAnchor :: TextAnchoring
    _txbdAnchorCenter :: Bool
    _txbdParagraphs :: [TextParagraph]
    ..} = Name -> [Element] -> Element
    elementListSimple Name
    nm (Element
    bodyPr Element -> [Element] -> [Element]
    forall a. a -> [a] -> [a]
    : [Element]
    paragraphs)
        where
          bodyPr :: Element
    bodyPr = Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    a_ Text
    "bodyPr") [(Name, Text)]
    bodyPrAttrs
          bodyPrAttrs :: [(Name, Text)]
    bodyPrAttrs =
            [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes
              [ Name
    "rot" Name -> Maybe Angle -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Angle -> Angle -> Maybe Angle
    forall a. Eq a => a -> a -> Maybe a
    justNonDef (Int -> Angle
    Angle Int
    0) Angle
    _txbdRotation
              , Name
    "spcFirstLastPara" Name -> Maybe Bool -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Bool -> Maybe Bool
    justTrue Bool
    _txbdSpcFirstLastPara
              , Name
    "vertOverflow" Name -> Maybe TextVertOverflow -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? TextVertOverflow -> TextVertOverflow -> Maybe TextVertOverflow
    forall a. Eq a => a -> a -> Maybe a
    justNonDef TextVertOverflow
    TextVertOverflow TextVertOverflow
    _txbdVertOverflow
              , Name
    "vert" Name -> Maybe TextVertical -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? TextVertical -> TextVertical -> Maybe TextVertical
    forall a. Eq a => a -> a -> Maybe a
    justNonDef TextVertical
    TextVerticalHorz TextVertical
    _txbdVertical
              , Name
    "wrap" Name -> Maybe TextWrap -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? TextWrap -> TextWrap -> Maybe TextWrap
    forall a. Eq a => a -> a -> Maybe a
    justNonDef TextWrap
    TextWrapSquare TextWrap
    _txbdWrap
              , Name
    "anchor" Name -> Maybe TextAnchoring -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? TextAnchoring -> TextAnchoring -> Maybe TextAnchoring
    forall a. Eq a => a -> a -> Maybe a
    justNonDef TextAnchoring
    TextAnchoringTop TextAnchoring
    _txbdAnchor
              , Name
    "anchorCtr" Name -> Maybe Bool -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Bool -> Maybe Bool
    justTrue Bool
    _txbdAnchorCenter
              ]
          paragraphs :: [Element]
    paragraphs = (TextParagraph -> Element) -> [TextParagraph] -> [Element]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name -> TextParagraph -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "p")) [TextParagraph]
    _txbdParagraphs

    instance ToElement TextParagraph where
      toElement :: Name -> TextParagraph -> Element
    toElement Name
    nm TextParagraph {[TextRun]
    Maybe TextCharacterProperties
    _txpaDefCharProps :: TextParagraph -> Maybe TextCharacterProperties
    _txpaRuns :: TextParagraph -> [TextRun]
    _txpaDefCharProps :: Maybe TextCharacterProperties
    _txpaRuns :: [TextRun]
    ..} = Name -> [Element] -> Element
    elementListSimple Name
    nm [Element]
    elements
        where
          elements :: [Element]
    elements =
            case Maybe TextCharacterProperties
    _txpaDefCharProps of
              Just TextCharacterProperties
    props -> (TextCharacterProperties -> Element
    forall {a}. ToElement a => a -> Element
    defRPr TextCharacterProperties
    props) Element -> [Element] -> [Element]
    forall a. a -> [a] -> [a]
    : [Element]
    runs
              Maybe TextCharacterProperties
    Nothing -> [Element]
    runs
          defRPr :: a -> Element
    defRPr a
    props =
            Name -> [Element] -> Element
    elementListSimple (Text -> Name
    a_ Text
    "pPr") [Name -> a -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "defRPr") a
    props]
          runs :: [Element]
    runs = (TextRun -> Element) -> [TextRun] -> [Element]
    forall a b. (a -> b) -> [a] -> [b]
    map (Name -> TextRun -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "r")) [TextRun]
    _txpaRuns

    instance ToElement TextCharacterProperties where
      toElement :: Name -> TextCharacterProperties -> Element
    toElement Name
    nm TextCharacterProperties {Bool
    _txchBold :: TextCharacterProperties -> Bool
    _txchItalic :: TextCharacterProperties -> Bool
    _txchUnderline :: TextCharacterProperties -> Bool
    _txchBold :: Bool
    _txchItalic :: Bool
    _txchUnderline :: Bool
    ..} = Name -> [(Name, Text)] -> Element
    leafElement Name
    nm [(Name, Text)]
    attrs
        where
          attrs :: [(Name, Text)]
    attrs = [Name
    "b" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    _txchBold, Name
    "i" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    _txchItalic, Name
    "u" Name -> Bool -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Bool
    _txchUnderline]

    instance ToElement TextRun where
      toElement :: Name -> TextRun -> Element
    toElement Name
    nm RegularRun {Maybe TextCharacterProperties
    Text
    _txrCharProps :: TextRun -> Maybe TextCharacterProperties
    _txrText :: TextRun -> Text
    _txrCharProps :: Maybe TextCharacterProperties
    _txrText :: Text
    ..} = Name -> [Element] -> Element
    elementListSimple Name
    nm [Element]
    elements
        where
          elements :: [Element]
    elements =
            [Maybe Element] -> [Element]
    forall a. [Maybe a] -> [a]
    catMaybes
              [ Name -> TextCharacterProperties -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "rPr") (TextCharacterProperties -> Element)
    -> Maybe TextCharacterProperties -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe TextCharacterProperties
    _txrCharProps
              , Element -> Maybe Element
    forall a. a -> Maybe a
    Just (Element -> Maybe Element) -> Element -> Maybe Element
    forall a b. (a -> b) -> a -> b
    $ Name -> Text -> Element
    elementContent (Text -> Name
    a_ Text
    "t") Text
    _txrText
              ]

    instance ToAttrVal TextVertOverflow where
      toAttrVal :: TextVertOverflow -> Text
    toAttrVal TextVertOverflow
    TextVertOverflow = Text
    "overflow"
      toAttrVal TextVertOverflow
    TextVertOverflowEllipsis = Text
    "ellipsis"
      toAttrVal TextVertOverflow
    TextVertOverflowClip = Text
    "clip"

    instance ToAttrVal TextVertical where
      toAttrVal :: TextVertical -> Text
    toAttrVal TextVertical
    TextVerticalHorz = Text
    "horz"
      toAttrVal TextVertical
    TextVertical = Text
    "vert"
      toAttrVal TextVertical
    TextVertical270 = Text
    "vert270"
      toAttrVal TextVertical
    TextVerticalWordArt = Text
    "wordArtVert"
      toAttrVal TextVertical
    TextVerticalEA = Text
    "eaVert"
      toAttrVal TextVertical
    TextVerticalMongolian = Text
    "mongolianVert"
      toAttrVal TextVertical
    TextVerticalWordArtRtl = Text
    "wordArtVertRtl"

    instance ToAttrVal TextWrap where
      toAttrVal :: TextWrap -> Text
    toAttrVal TextWrap
    TextWrapNone = Text
    "none"
      toAttrVal TextWrap
    TextWrapSquare = Text
    "square"

    -- See 20.1.10.59 "ST_TextAnchoringType (Text Anchoring Types)" (p. 3058)
    instance ToAttrVal TextAnchoring where
      toAttrVal :: TextAnchoring -> Text
    toAttrVal TextAnchoring
    TextAnchoringTop = Text
    "t"
      toAttrVal TextAnchoring
    TextAnchoringCenter = Text
    "ctr"
      toAttrVal TextAnchoring
    TextAnchoringBottom = Text
    "b"
      toAttrVal TextAnchoring
    TextAnchoringJustified = Text
    "just"
      toAttrVal TextAnchoring
    TextAnchoringDistributed = Text
    "dist"

    instance ToAttrVal Angle where
      toAttrVal :: Angle -> Text
    toAttrVal (Angle Int
    x) = Int -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Int
    x

    instance ToElement ShapeProperties where
        toElement :: Name -> ShapeProperties -> Element
    toElement Name
    nm ShapeProperties{Maybe FillProperties
    Maybe LineProperties
    Maybe Geometry
    Maybe Transform2D
    _spXfrm :: ShapeProperties -> Maybe Transform2D
    _spGeometry :: ShapeProperties -> Maybe Geometry
    _spFill :: ShapeProperties -> Maybe FillProperties
    _spOutline :: ShapeProperties -> Maybe LineProperties
    _spXfrm :: Maybe Transform2D
    _spGeometry :: Maybe Geometry
    _spFill :: Maybe FillProperties
    _spOutline :: Maybe LineProperties
    ..} = Name -> [Element] -> Element
    elementListSimple Name
    nm [Element]
    elements
          where
            elements :: [Element]
    elements = [Maybe Element] -> [Element]
    forall a. [Maybe a] -> [a]
    catMaybes [ Name -> Transform2D -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "xfrm") (Transform2D -> Element) -> Maybe Transform2D -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Transform2D
    _spXfrm
                                 , Geometry -> Element
    geometryToElement (Geometry -> Element) -> Maybe Geometry -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Geometry
    _spGeometry
                                 , FillProperties -> Element
    fillPropsToElement (FillProperties -> Element)
    -> Maybe FillProperties -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe FillProperties
    _spFill
                                 , Name -> LineProperties -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "ln")  (LineProperties -> Element)
    -> Maybe LineProperties -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe LineProperties
    _spOutline ]

    instance ToElement Point2D where
        toElement :: Name -> Point2D -> Element
    toElement Name
    nm Point2D{Coordinate
    _pt2dX :: Point2D -> Coordinate
    _pt2dY :: Point2D -> Coordinate
    _pt2dX :: Coordinate
    _pt2dY :: Coordinate
    ..} = Name -> [(Name, Text)] -> Element
    leafElement Name
    nm [ Name
    "x" Name -> Coordinate -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Coordinate
    _pt2dX
                                                  , Name
    "y" Name -> Coordinate -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Coordinate
    _pt2dY
                                                  ]

    instance ToElement PositiveSize2D where
        toElement :: Name -> PositiveSize2D -> Element
    toElement Name
    nm PositiveSize2D{PositiveCoordinate
    _ps2dX :: PositiveSize2D -> PositiveCoordinate
    _ps2dY :: PositiveSize2D -> PositiveCoordinate
    _ps2dX :: PositiveCoordinate
    _ps2dY :: PositiveCoordinate
    ..} = Name -> [(Name, Text)] -> Element
    leafElement Name
    nm [ Name
    "cx" Name -> PositiveCoordinate -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= PositiveCoordinate
    _ps2dX
                                                         , Name
    "cy" Name -> PositiveCoordinate -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= PositiveCoordinate
    _ps2dY ]

    instance ToAttrVal Coordinate where
        toAttrVal :: Coordinate -> Text
    toAttrVal (UnqCoordinate Int
    x) = Int -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Int
    x
        toAttrVal (UniversalMeasure UnitIdentifier
    unit Double
    x) = Double -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Double
    x Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> UnitIdentifier -> Text
    forall {a}. IsString a => UnitIdentifier -> a
    unitToText UnitIdentifier
    unit
          where
            unitToText :: UnitIdentifier -> a
    unitToText UnitIdentifier
    UnitCm = a
    "cm"
            unitToText UnitIdentifier
    UnitMm = a
    "mm"
            unitToText UnitIdentifier
    UnitIn = a
    "in"
            unitToText UnitIdentifier
    UnitPt = a
    "pt"
            unitToText UnitIdentifier
    UnitPc = a
    "pc"
            unitToText UnitIdentifier
    UnitPi = a
    "pi"

    instance ToAttrVal PositiveCoordinate where
        toAttrVal :: PositiveCoordinate -> Text
    toAttrVal (PositiveCoordinate Integer
    x) = Integer -> Text
    forall a. ToAttrVal a => a -> Text
    toAttrVal Integer
    x

    instance ToElement Transform2D where
        toElement :: Name -> Transform2D -> Element
    toElement Name
    nm Transform2D{Bool
    Maybe PositiveSize2D
    Maybe Point2D
    Angle
    _trRot :: Transform2D -> Angle
    _trFlipH :: Transform2D -> Bool
    _trFlipV :: Transform2D -> Bool
    _trOffset :: Transform2D -> Maybe Point2D
    _trExtents :: Transform2D -> Maybe PositiveSize2D
    _trRot :: Angle
    _trFlipH :: Bool
    _trFlipV :: Bool
    _trOffset :: Maybe Point2D
    _trExtents :: Maybe PositiveSize2D
    ..} = Name -> [(Name, Text)] -> [Element] -> Element
    elementList Name
    nm [(Name, Text)]
    attrs [Element]
    elements
          where
            attrs :: [(Name, Text)]
    attrs = [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [ Name
    "rot"   Name -> Maybe Angle -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Angle -> Angle -> Maybe Angle
    forall a. Eq a => a -> a -> Maybe a
    justNonDef (Int -> Angle
    Angle Int
    0) Angle
    _trRot
                              , Name
    "flipH" Name -> Maybe Bool -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Bool -> Maybe Bool
    justTrue Bool
    _trFlipH
                              , Name
    "flipV" Name -> Maybe Bool -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Bool -> Maybe Bool
    justTrue Bool
    _trFlipV ]
            elements :: [Element]
    elements = [Maybe Element] -> [Element]
    forall a. [Maybe a] -> [a]
    catMaybes [ Name -> Point2D -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "off") (Point2D -> Element) -> Maybe Point2D -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Point2D
    _trOffset
                                 , Name -> PositiveSize2D -> Element
    forall a. ToElement a => Name -> a -> Element
    toElement (Text -> Name
    a_ Text
    "ext") (PositiveSize2D -> Element)
    -> Maybe PositiveSize2D -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe PositiveSize2D
    _trExtents ]

    geometryToElement :: Geometry -> Element
    geometryToElement :: Geometry -> Element
    geometryToElement Geometry
    PresetGeometry =
      Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    a_ Text
    "prstGeom") [Name
    "prst" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= (Text
    "rect" :: Text)]

    instance ToElement LineProperties where
      toElement :: Name -> LineProperties -> Element
    toElement Name
    nm LineProperties {Int
    Maybe FillProperties
    _lnFill :: LineProperties -> Maybe FillProperties
    _lnWidth :: LineProperties -> Int
    _lnFill :: Maybe FillProperties
    _lnWidth :: Int
    ..} = Name -> [(Name, Text)] -> [Element] -> Element
    elementList Name
    nm [(Name, Text)]
    attrs [Element]
    elements
        where
          attrs :: [(Name, Text)]
    attrs = [Maybe (Name, Text)] -> [(Name, Text)]
    forall a. [Maybe a] -> [a]
    catMaybes [Name
    "w" Name -> Maybe Int -> Maybe (Name, Text)
    forall a. ToAttrVal a => Name -> Maybe a -> Maybe (Name, Text)
    .=? Int -> Int -> Maybe Int
    forall a. Eq a => a -> a -> Maybe a
    justNonDef Int
    0 Int
    _lnWidth]
          elements :: [Element]
    elements = [Maybe Element] -> [Element]
    forall a. [Maybe a] -> [a]
    catMaybes [FillProperties -> Element
    fillPropsToElement (FillProperties -> Element)
    -> Maybe FillProperties -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe FillProperties
    _lnFill]

    fillPropsToElement :: FillProperties -> Element
    fillPropsToElement :: FillProperties -> Element
    fillPropsToElement FillProperties
    NoFill = Name -> Element
    emptyElement (Text -> Name
    a_ Text
    "noFill")
    fillPropsToElement (SolidFill Maybe ColorChoice
    color) =
      Name -> [Element] -> Element
    elementListSimple (Text -> Name
    a_ Text
    "solidFill") ([Element] -> Element) -> [Element] -> Element
    forall a b. (a -> b) -> a -> b
    $ [Maybe Element] -> [Element]
    forall a. [Maybe a] -> [a]
    catMaybes [ColorChoice -> Element
    colorChoiceToElement (ColorChoice -> Element) -> Maybe ColorChoice -> Maybe Element
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe ColorChoice
    color]

    colorChoiceToElement :: ColorChoice -> Element
    colorChoiceToElement :: ColorChoice -> Element
    colorChoiceToElement (RgbColor Text
    color) =
      Name -> [(Name, Text)] -> Element
    leafElement (Text -> Name
    a_ Text
    "srgbClr") [Name
    "val" Name -> Text -> (Name, Text)
    forall a. ToAttrVal a => Name -> a -> (Name, Text)
    .= Text
    color]

    -- | Add DrawingML namespace to name
    a_ :: Text -> Name
    a_ :: Text -> Name
    a_ Text
    x =
      Name {nameLocalName :: Text
    nameLocalName = Text
    x, nameNamespace :: Maybe Text
    nameNamespace = Text -> Maybe Text
    forall a. a -> Maybe a
    Just Text
    drawingNs, namePrefix :: Maybe Text
    namePrefix = Text -> Maybe Text
    forall a. a -> Maybe a
    Just Text
    "a"}

    drawingNs :: Text
    drawingNs :: Text
    drawingNs = Text
    "http://schemas.openxmlformats.org/drawingml/2006/main"