{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
module Codec.Xlsx.Types.RichText (
RichTextRun(..)
, RunProperties(..)
, applyRunProperties
, richTextRunProperties
, richTextRunText
, runPropertiesBold
, runPropertiesCharset
, runPropertiesColor
, runPropertiesCondense
, runPropertiesExtend
, runPropertiesFontFamily
, runPropertiesItalic
, runPropertiesOutline
, runPropertiesFont
, runPropertiesScheme
, runPropertiesShadow
, runPropertiesStrikeThrough
, runPropertiesSize
, runPropertiesUnderline
, runPropertiesVertAlign
) where
import GHC.Generics (Generic)
#ifdef USE_MICROLENS
import Lens.Micro.TH (makeLenses)
#else
import Control.Lens hiding (element)
#endif
import Control.Monad
import Control.DeepSeq (NFData)
import Data.Default
import Data.Maybe (catMaybes)
import Data.Text (Text)
import Text.XML
import Text.XML.Cursor
import qualified Data.Map as Map
import Codec.Xlsx.Parser.Internal
import Codec.Xlsx.Types.StyleSheet
import Codec.Xlsx.Writer.Internal
data RichTextRun = RichTextRun {
RichTextRun -> Maybe RunProperties
_richTextRunProperties :: Maybe RunProperties
, RichTextRun -> Text
_richTextRunText :: Text
}
deriving (RichTextRun -> RichTextRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RichTextRun -> RichTextRun -> Bool
$c/= :: RichTextRun -> RichTextRun -> Bool
== :: RichTextRun -> RichTextRun -> Bool
$c== :: RichTextRun -> RichTextRun -> Bool
Eq, Eq RichTextRun
RichTextRun -> RichTextRun -> Bool
RichTextRun -> RichTextRun -> Ordering
RichTextRun -> RichTextRun -> RichTextRun
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
min :: RichTextRun -> RichTextRun -> RichTextRun
$cmin :: RichTextRun -> RichTextRun -> RichTextRun
max :: RichTextRun -> RichTextRun -> RichTextRun
$cmax :: RichTextRun -> RichTextRun -> RichTextRun
>= :: RichTextRun -> RichTextRun -> Bool
$c>= :: RichTextRun -> RichTextRun -> Bool
> :: RichTextRun -> RichTextRun -> Bool
$c> :: RichTextRun -> RichTextRun -> Bool
<= :: RichTextRun -> RichTextRun -> Bool
$c<= :: RichTextRun -> RichTextRun -> Bool
< :: RichTextRun -> RichTextRun -> Bool
$c< :: RichTextRun -> RichTextRun -> Bool
compare :: RichTextRun -> RichTextRun -> Ordering
$ccompare :: RichTextRun -> RichTextRun -> Ordering
Ord, Int -> RichTextRun -> ShowS
[RichTextRun] -> ShowS
RichTextRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RichTextRun] -> ShowS
$cshowList :: [RichTextRun] -> ShowS
show :: RichTextRun -> String
$cshow :: RichTextRun -> String
showsPrec :: Int -> RichTextRun -> ShowS
$cshowsPrec :: Int -> RichTextRun -> ShowS
Show, forall x. Rep RichTextRun x -> RichTextRun
forall x. RichTextRun -> Rep RichTextRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RichTextRun x -> RichTextRun
$cfrom :: forall x. RichTextRun -> Rep RichTextRun x
Generic)
instance NFData RichTextRun
data RunProperties = RunProperties {
RunProperties -> Maybe Bool
_runPropertiesBold :: Maybe Bool
, RunProperties -> Maybe Int
_runPropertiesCharset :: Maybe Int
, RunProperties -> Maybe Color
_runPropertiesColor :: Maybe Color
, RunProperties -> Maybe Bool
_runPropertiesCondense :: Maybe Bool
, RunProperties -> Maybe Bool
_runPropertiesExtend :: Maybe Bool
, RunProperties -> Maybe FontFamily
_runPropertiesFontFamily :: Maybe FontFamily
, RunProperties -> Maybe Bool
_runPropertiesItalic :: Maybe Bool
, RunProperties -> Maybe Bool
_runPropertiesOutline :: Maybe Bool
, RunProperties -> Maybe Text
_runPropertiesFont :: Maybe Text
, RunProperties -> Maybe FontScheme
_runPropertiesScheme :: Maybe FontScheme
, RunProperties -> Maybe Bool
_runPropertiesShadow :: Maybe Bool
, RunProperties -> Maybe Bool
_runPropertiesStrikeThrough :: Maybe Bool
, RunProperties -> Maybe Double
_runPropertiesSize :: Maybe Double
, RunProperties -> Maybe FontUnderline
_runPropertiesUnderline :: Maybe FontUnderline
, RunProperties -> Maybe FontVerticalAlignment
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
}
deriving (RunProperties -> RunProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RunProperties -> RunProperties -> Bool
$c/= :: RunProperties -> RunProperties -> Bool
== :: RunProperties -> RunProperties -> Bool
$c== :: RunProperties -> RunProperties -> Bool
Eq, Eq RunProperties
RunProperties -> RunProperties -> Bool
RunProperties -> RunProperties -> Ordering
RunProperties -> RunProperties -> RunProperties
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
min :: RunProperties -> RunProperties -> RunProperties
$cmin :: RunProperties -> RunProperties -> RunProperties
max :: RunProperties -> RunProperties -> RunProperties
$cmax :: RunProperties -> RunProperties -> RunProperties
>= :: RunProperties -> RunProperties -> Bool
$c>= :: RunProperties -> RunProperties -> Bool
> :: RunProperties -> RunProperties -> Bool
$c> :: RunProperties -> RunProperties -> Bool
<= :: RunProperties -> RunProperties -> Bool
$c<= :: RunProperties -> RunProperties -> Bool
< :: RunProperties -> RunProperties -> Bool
$c< :: RunProperties -> RunProperties -> Bool
compare :: RunProperties -> RunProperties -> Ordering
$ccompare :: RunProperties -> RunProperties -> Ordering
Ord, Int -> RunProperties -> ShowS
[RunProperties] -> ShowS
RunProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RunProperties] -> ShowS
$cshowList :: [RunProperties] -> ShowS
show :: RunProperties -> String
$cshow :: RunProperties -> String
showsPrec :: Int -> RunProperties -> ShowS
$cshowsPrec :: Int -> RunProperties -> ShowS
Show, forall x. Rep RunProperties x -> RunProperties
forall x. RunProperties -> Rep RunProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RunProperties x -> RunProperties
$cfrom :: forall x. RunProperties -> Rep RunProperties x
Generic)
instance NFData RunProperties
makeLenses ''RichTextRun
makeLenses ''RunProperties
instance Default RichTextRun where
def :: RichTextRun
def = RichTextRun {
_richTextRunProperties :: Maybe RunProperties
_richTextRunProperties = forall a. Maybe a
Nothing
, _richTextRunText :: Text
_richTextRunText = Text
""
}
instance Default RunProperties where
def :: RunProperties
def = RunProperties {
_runPropertiesBold :: Maybe Bool
_runPropertiesBold = forall a. Maybe a
Nothing
, _runPropertiesCharset :: Maybe Int
_runPropertiesCharset = forall a. Maybe a
Nothing
, _runPropertiesColor :: Maybe Color
_runPropertiesColor = forall a. Maybe a
Nothing
, _runPropertiesCondense :: Maybe Bool
_runPropertiesCondense = forall a. Maybe a
Nothing
, _runPropertiesExtend :: Maybe Bool
_runPropertiesExtend = forall a. Maybe a
Nothing
, _runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesFontFamily = forall a. Maybe a
Nothing
, _runPropertiesItalic :: Maybe Bool
_runPropertiesItalic = forall a. Maybe a
Nothing
, _runPropertiesOutline :: Maybe Bool
_runPropertiesOutline = forall a. Maybe a
Nothing
, _runPropertiesFont :: Maybe Text
_runPropertiesFont = forall a. Maybe a
Nothing
, _runPropertiesScheme :: Maybe FontScheme
_runPropertiesScheme = forall a. Maybe a
Nothing
, _runPropertiesShadow :: Maybe Bool
_runPropertiesShadow = forall a. Maybe a
Nothing
, _runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesStrikeThrough = forall a. Maybe a
Nothing
, _runPropertiesSize :: Maybe Double
_runPropertiesSize = forall a. Maybe a
Nothing
, _runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesUnderline = forall a. Maybe a
Nothing
, _runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesVertAlign = forall a. Maybe a
Nothing
}
instance ToElement RichTextRun where
toElement :: Name -> RichTextRun -> Element
toElement Name
nm RichTextRun{Maybe RunProperties
Text
_richTextRunText :: Text
_richTextRunProperties :: Maybe RunProperties
_richTextRunText :: RichTextRun -> Text
_richTextRunProperties :: RichTextRun -> Maybe RunProperties
..} = Element {
elementName :: Name
elementName = Name
nm
, elementAttributes :: Map Name Text
elementAttributes = forall k a. Map k a
Map.empty
, elementNodes :: [Node]
elementNodes = forall a b. (a -> b) -> [a] -> [b]
map Element -> Node
NodeElement forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall a b. (a -> b) -> a -> b
$ [
forall a. ToElement a => Name -> a -> Element
toElement Name
"rPr" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe RunProperties
_richTextRunProperties
, forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Name -> Text -> Element
elementContentPreserved Name
"t" Text
_richTextRunText
]
}
instance ToElement RunProperties where
toElement :: Name -> RunProperties -> Element
toElement Name
nm RunProperties{Maybe Bool
Maybe Double
Maybe Int
Maybe Text
Maybe FontVerticalAlignment
Maybe FontUnderline
Maybe FontScheme
Maybe FontFamily
Maybe Color
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesSize :: Maybe Double
_runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesShadow :: Maybe Bool
_runPropertiesScheme :: Maybe FontScheme
_runPropertiesFont :: Maybe Text
_runPropertiesOutline :: Maybe Bool
_runPropertiesItalic :: Maybe Bool
_runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesExtend :: Maybe Bool
_runPropertiesCondense :: Maybe Bool
_runPropertiesColor :: Maybe Color
_runPropertiesCharset :: Maybe Int
_runPropertiesBold :: Maybe Bool
_runPropertiesVertAlign :: RunProperties -> Maybe FontVerticalAlignment
_runPropertiesUnderline :: RunProperties -> Maybe FontUnderline
_runPropertiesSize :: RunProperties -> Maybe Double
_runPropertiesStrikeThrough :: RunProperties -> Maybe Bool
_runPropertiesShadow :: RunProperties -> Maybe Bool
_runPropertiesScheme :: RunProperties -> Maybe FontScheme
_runPropertiesFont :: RunProperties -> Maybe Text
_runPropertiesOutline :: RunProperties -> Maybe Bool
_runPropertiesItalic :: RunProperties -> Maybe Bool
_runPropertiesFontFamily :: RunProperties -> Maybe FontFamily
_runPropertiesExtend :: RunProperties -> Maybe Bool
_runPropertiesCondense :: RunProperties -> Maybe Bool
_runPropertiesColor :: RunProperties -> Maybe Color
_runPropertiesCharset :: RunProperties -> Maybe Int
_runPropertiesBold :: RunProperties -> Maybe Bool
..} = Element {
elementName :: Name
elementName = Name
nm
, elementAttributes :: Map Name Text
elementAttributes = forall k a. Map k a
Map.empty
, elementNodes :: [Node]
elementNodes = forall a b. (a -> b) -> [a] -> [b]
map Element -> Node
NodeElement forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [Maybe a] -> [a]
catMaybes forall a b. (a -> b) -> a -> b
$ [
forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"rFont" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
_runPropertiesFont
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"charset" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Int
_runPropertiesCharset
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"family" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe FontFamily
_runPropertiesFontFamily
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"b" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesBold
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"i" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesItalic
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"strike" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesStrikeThrough
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"outline" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesOutline
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"shadow" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesShadow
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"condense" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesCondense
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"extend" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
_runPropertiesExtend
, forall a. ToElement a => Name -> a -> Element
toElement Name
"color" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Color
_runPropertiesColor
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"sz" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Double
_runPropertiesSize
, forall a. (Eq a, ToAttrVal a) => Name -> a -> a -> Element
elementValueDef Name
"u" FontUnderline
FontUnderlineSingle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe FontUnderline
_runPropertiesUnderline
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"vertAlign" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe FontVerticalAlignment
_runPropertiesVertAlign
, forall a. ToAttrVal a => Name -> a -> Element
elementValue Name
"scheme" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe FontScheme
_runPropertiesScheme
]
}
instance FromCursor RichTextRun where
fromCursor :: Cursor -> [RichTextRun]
fromCursor Cursor
cur = do
Text
_richTextRunText <- Cursor
cur forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
n_ Text
"t") forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
content
Maybe RunProperties
_richTextRunProperties <- forall a. FromCursor a => Name -> Cursor -> [Maybe a]
maybeFromElement (Text -> Name
n_ Text
"rPr") Cursor
cur
forall (m :: * -> *) a. Monad m => a -> m a
return RichTextRun{Maybe RunProperties
Text
_richTextRunProperties :: Maybe RunProperties
_richTextRunText :: Text
_richTextRunText :: Text
_richTextRunProperties :: Maybe RunProperties
..}
instance FromXenoNode RichTextRun where
fromXenoNode :: Node -> Either Text RichTextRun
fromXenoNode Node
root = do
(Maybe Node
prNode, Node
tNode) <- forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root forall a b. (a -> b) -> a -> b
$ (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> ChildCollector (Maybe Node)
maybeChild ByteString
"rPr" forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> ChildCollector Node
requireChild ByteString
"t"
Maybe RunProperties
_richTextRunProperties <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM forall a. FromXenoNode a => Node -> Either Text a
fromXenoNode Maybe Node
prNode
Text
_richTextRunText <- Node -> Either Text Text
contentX Node
tNode
forall (m :: * -> *) a. Monad m => a -> m a
return RichTextRun {Maybe RunProperties
Text
_richTextRunText :: Text
_richTextRunProperties :: Maybe RunProperties
_richTextRunText :: Text
_richTextRunProperties :: Maybe RunProperties
..}
instance FromCursor RunProperties where
fromCursor :: Cursor -> [RunProperties]
fromCursor Cursor
cur = do
Maybe Text
_runPropertiesFont <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"rFont") Cursor
cur
Maybe Int
_runPropertiesCharset <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"charset") Cursor
cur
Maybe FontFamily
_runPropertiesFontFamily <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"family") Cursor
cur
Maybe Bool
_runPropertiesBold <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"b") Cursor
cur
Maybe Bool
_runPropertiesItalic <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"i") Cursor
cur
Maybe Bool
_runPropertiesStrikeThrough <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"strike") Cursor
cur
Maybe Bool
_runPropertiesOutline <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"outline") Cursor
cur
Maybe Bool
_runPropertiesShadow <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"shadow") Cursor
cur
Maybe Bool
_runPropertiesCondense <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"condense") Cursor
cur
Maybe Bool
_runPropertiesExtend <- Name -> Cursor -> [Maybe Bool]
maybeBoolElementValue (Text -> Name
n_ Text
"extend") Cursor
cur
Maybe Color
_runPropertiesColor <- forall a. FromCursor a => Name -> Cursor -> [Maybe a]
maybeFromElement (Text -> Name
n_ Text
"color") Cursor
cur
Maybe Double
_runPropertiesSize <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"sz") Cursor
cur
Maybe FontUnderline
_runPropertiesUnderline <- forall a. FromAttrVal a => Name -> a -> Cursor -> [Maybe a]
maybeElementValueDef (Text -> Name
n_ Text
"u") FontUnderline
FontUnderlineSingle Cursor
cur
Maybe FontVerticalAlignment
_runPropertiesVertAlign <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"vertAlign") Cursor
cur
Maybe FontScheme
_runPropertiesScheme <- forall a. FromAttrVal a => Name -> Cursor -> [Maybe a]
maybeElementValue (Text -> Name
n_ Text
"scheme") Cursor
cur
forall (m :: * -> *) a. Monad m => a -> m a
return RunProperties{Maybe Bool
Maybe Double
Maybe Int
Maybe Text
Maybe FontVerticalAlignment
Maybe FontUnderline
Maybe FontScheme
Maybe FontFamily
Maybe Color
_runPropertiesScheme :: Maybe FontScheme
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesSize :: Maybe Double
_runPropertiesColor :: Maybe Color
_runPropertiesExtend :: Maybe Bool
_runPropertiesCondense :: Maybe Bool
_runPropertiesShadow :: Maybe Bool
_runPropertiesOutline :: Maybe Bool
_runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesItalic :: Maybe Bool
_runPropertiesBold :: Maybe Bool
_runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesCharset :: Maybe Int
_runPropertiesFont :: Maybe Text
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesSize :: Maybe Double
_runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesShadow :: Maybe Bool
_runPropertiesScheme :: Maybe FontScheme
_runPropertiesFont :: Maybe Text
_runPropertiesOutline :: Maybe Bool
_runPropertiesItalic :: Maybe Bool
_runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesExtend :: Maybe Bool
_runPropertiesCondense :: Maybe Bool
_runPropertiesColor :: Maybe Color
_runPropertiesCharset :: Maybe Int
_runPropertiesBold :: Maybe Bool
..}
instance FromXenoNode RunProperties where
fromXenoNode :: Node -> Either Text RunProperties
fromXenoNode Node
root = forall a. Node -> ChildCollector a -> Either Text a
collectChildren Node
root forall a b. (a -> b) -> a -> b
$ do
Maybe Text
_runPropertiesFont <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"rFont"
Maybe Int
_runPropertiesCharset <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"charset"
Maybe FontFamily
_runPropertiesFontFamily <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"family"
Maybe Bool
_runPropertiesBold <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"b"
Maybe Bool
_runPropertiesItalic <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"i"
Maybe Bool
_runPropertiesStrikeThrough <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"strike"
Maybe Bool
_runPropertiesOutline <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"outline"
Maybe Bool
_runPropertiesShadow <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"shadow"
Maybe Bool
_runPropertiesCondense <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"condense"
Maybe Bool
_runPropertiesExtend <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"extend"
Maybe Color
_runPropertiesColor <- forall a. FromXenoNode a => ByteString -> ChildCollector (Maybe a)
maybeFromChild ByteString
"color"
Maybe Double
_runPropertiesSize <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"sz"
Maybe FontUnderline
_runPropertiesUnderline <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"u"
Maybe FontVerticalAlignment
_runPropertiesVertAlign <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"vertAlign"
Maybe FontScheme
_runPropertiesScheme <- forall a. FromAttrBs a => ByteString -> ChildCollector (Maybe a)
maybeElementVal ByteString
"scheme"
forall (m :: * -> *) a. Monad m => a -> m a
return RunProperties{Maybe Bool
Maybe Double
Maybe Int
Maybe Text
Maybe FontVerticalAlignment
Maybe FontUnderline
Maybe FontScheme
Maybe FontFamily
Maybe Color
_runPropertiesScheme :: Maybe FontScheme
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesSize :: Maybe Double
_runPropertiesColor :: Maybe Color
_runPropertiesExtend :: Maybe Bool
_runPropertiesCondense :: Maybe Bool
_runPropertiesShadow :: Maybe Bool
_runPropertiesOutline :: Maybe Bool
_runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesItalic :: Maybe Bool
_runPropertiesBold :: Maybe Bool
_runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesCharset :: Maybe Int
_runPropertiesFont :: Maybe Text
_runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesSize :: Maybe Double
_runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesShadow :: Maybe Bool
_runPropertiesScheme :: Maybe FontScheme
_runPropertiesFont :: Maybe Text
_runPropertiesOutline :: Maybe Bool
_runPropertiesItalic :: Maybe Bool
_runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesExtend :: Maybe Bool
_runPropertiesCondense :: Maybe Bool
_runPropertiesColor :: Maybe Color
_runPropertiesCharset :: Maybe Int
_runPropertiesBold :: Maybe Bool
..}
#if (MIN_VERSION_base(4,11,0))
instance Semigroup RunProperties where
RunProperties
a <> :: RunProperties -> RunProperties -> RunProperties
<> RunProperties
b = RunProperties {
_runPropertiesBold :: Maybe Bool
_runPropertiesBold = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesBold
, _runPropertiesCharset :: Maybe Int
_runPropertiesCharset = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Int
_runPropertiesCharset
, _runPropertiesColor :: Maybe Color
_runPropertiesColor = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Color
_runPropertiesColor
, _runPropertiesCondense :: Maybe Bool
_runPropertiesCondense = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesCondense
, _runPropertiesExtend :: Maybe Bool
_runPropertiesExtend = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesExtend
, _runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesFontFamily = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontFamily
_runPropertiesFontFamily
, _runPropertiesItalic :: Maybe Bool
_runPropertiesItalic = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesItalic
, _runPropertiesOutline :: Maybe Bool
_runPropertiesOutline = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesOutline
, _runPropertiesFont :: Maybe Text
_runPropertiesFont = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Text
_runPropertiesFont
, _runPropertiesScheme :: Maybe FontScheme
_runPropertiesScheme = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontScheme
_runPropertiesScheme
, _runPropertiesShadow :: Maybe Bool
_runPropertiesShadow = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesShadow
, _runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesStrikeThrough = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesStrikeThrough
, _runPropertiesSize :: Maybe Double
_runPropertiesSize = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Double
_runPropertiesSize
, _runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesUnderline = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontUnderline
_runPropertiesUnderline
, _runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesVertAlign = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontVerticalAlignment
_runPropertiesVertAlign
}
where
override :: (RunProperties -> Maybe x) -> Maybe x
override :: forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe x
f = RunProperties -> Maybe x
f RunProperties
b forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` RunProperties -> Maybe x
f RunProperties
a
#endif
instance Monoid RunProperties where
mempty :: RunProperties
mempty = forall a. Default a => a
def
RunProperties
a mappend :: RunProperties -> RunProperties -> RunProperties
`mappend` RunProperties
b = RunProperties {
_runPropertiesBold :: Maybe Bool
_runPropertiesBold = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesBold
, _runPropertiesCharset :: Maybe Int
_runPropertiesCharset = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Int
_runPropertiesCharset
, _runPropertiesColor :: Maybe Color
_runPropertiesColor = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Color
_runPropertiesColor
, _runPropertiesCondense :: Maybe Bool
_runPropertiesCondense = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesCondense
, _runPropertiesExtend :: Maybe Bool
_runPropertiesExtend = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesExtend
, _runPropertiesFontFamily :: Maybe FontFamily
_runPropertiesFontFamily = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontFamily
_runPropertiesFontFamily
, _runPropertiesItalic :: Maybe Bool
_runPropertiesItalic = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesItalic
, _runPropertiesOutline :: Maybe Bool
_runPropertiesOutline = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesOutline
, _runPropertiesFont :: Maybe Text
_runPropertiesFont = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Text
_runPropertiesFont
, _runPropertiesScheme :: Maybe FontScheme
_runPropertiesScheme = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontScheme
_runPropertiesScheme
, _runPropertiesShadow :: Maybe Bool
_runPropertiesShadow = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesShadow
, _runPropertiesStrikeThrough :: Maybe Bool
_runPropertiesStrikeThrough = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Bool
_runPropertiesStrikeThrough
, _runPropertiesSize :: Maybe Double
_runPropertiesSize = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe Double
_runPropertiesSize
, _runPropertiesUnderline :: Maybe FontUnderline
_runPropertiesUnderline = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontUnderline
_runPropertiesUnderline
, _runPropertiesVertAlign :: Maybe FontVerticalAlignment
_runPropertiesVertAlign = forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe FontVerticalAlignment
_runPropertiesVertAlign
}
where
override :: (RunProperties -> Maybe x) -> Maybe x
override :: forall x. (RunProperties -> Maybe x) -> Maybe x
override RunProperties -> Maybe x
f = RunProperties -> Maybe x
f RunProperties
b forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` RunProperties -> Maybe x
f RunProperties
a
applyRunProperties :: RunProperties -> RichTextRun -> RichTextRun
applyRunProperties :: RunProperties -> RichTextRun -> RichTextRun
applyRunProperties RunProperties
p (RichTextRun Maybe RunProperties
Nothing Text
t) = Maybe RunProperties -> Text -> RichTextRun
RichTextRun (forall a. a -> Maybe a
Just RunProperties
p) Text
t
applyRunProperties RunProperties
p (RichTextRun (Just RunProperties
p') Text
t) = Maybe RunProperties -> Text -> RichTextRun
RichTextRun (forall a. a -> Maybe a
Just (RunProperties
p forall a. Monoid a => a -> a -> a
`mappend` RunProperties
p')) Text
t