@@ -158,6 +158,7 @@ data ParagraphStyle = ParagraphStyle { pStyle :: [String]
158 , indentation :: Maybe ParIndentation
158 , indentation :: Maybe ParIndentation
159 , dropCap :: Bool
159 , dropCap :: Bool
160 , pHeading :: Maybe (String, Int)
160 , pHeading :: Maybe (String, Int)
161+ , pNumInfo :: Maybe (String, String)
161 , pBlockQuote :: Maybe Bool
162 , pBlockQuote :: Maybe Bool
163 deriving Show
164 deriving Show
@@ -167,6 +168,7 @@ defaultParagraphStyle = ParagraphStyle { pStyle = []
167 , indentation = Nothing
168 , indentation = Nothing
168 , dropCap = False
169 , dropCap = False
169 , pHeading = Nothing
170 , pHeading = Nothing
171+ , pNumInfo = Nothing
170 , pBlockQuote = Nothing
172 , pBlockQuote = Nothing
@@ -224,6 +226,7 @@ data RunStyle = RunStyle { isBold :: Maybe Bool
225data ParStyleData = ParStyleData { headingLev :: Maybe (String, Int)
227data ParStyleData = ParStyleData { headingLev :: Maybe (String, Int)
226 , isBlockQuote :: Maybe Bool
228 , isBlockQuote :: Maybe Bool
229+ , numInfo :: Maybe (String, String)
227 , psStyle :: Maybe ParStyle}
230 , psStyle :: Maybe ParStyle}
228 deriving Show
231 deriving Show
@@ -546,20 +549,6 @@ elemToParIndentation ns element | isElem ns "w" "ind" element =
546 stringToInteger}
549 stringToInteger}
547elemToParIndentation _ _ = Nothing
550elemToParIndentation _ _ = Nothing
550−elemToNumInfo :: NameSpaces -> Element -> Maybe (String, String)
551−elemToNumInfo ns element | isElem ns "w" "p" element = do
552− let pPr = findChild (elemName ns "w" "pPr") element
553− numPr = pPr >>= findChild (elemName ns "w" "numPr")
555− findChild (elemName ns "w" "ilvl") >>=
556− findAttr (elemName ns "w" "val")
558− findChild (elemName ns "w" "numId") >>=
559− findAttr (elemName ns "w" "val")
561−elemToNumInfo _ _ = Nothing
563testBitMask :: String -> Int -> Bool
552testBitMask :: String -> Int -> Bool
564testBitMask bitMaskS n =
553testBitMask bitMaskS n =
565 case (reads ("0x" ++ bitMaskS) :: [(Int, String)]) of
554 case (reads ("0x" ++ bitMaskS) :: [(Int, String)]) of
@@ -578,20 +567,28 @@ elemToBodyPart ns element
578 return $ OMathPara expsLst
567 return $ OMathPara expsLst
579elemToBodyPart ns element
568elemToBodyPart ns element
580 | isElem ns "w" "p" element
569 | isElem ns "w" "p" element
581− , Just (numId, lvl) <- elemToNumInfo ns element = do
570+ , Just (numId, lvl) <- getNumInfo ns element = do
582 sty <- asks envParStyles
571 sty <- asks envParStyles
583 let parstyle = elemToParagraphStyle ns element sty
572 let parstyle = elemToParagraphStyle ns element sty
584 parparts <- mapD (elemToParPart ns) (elChildren element)
573 parparts <- mapD (elemToParPart ns) (elChildren element)
585 num <- asks envNumbering
574 num <- asks envNumbering
586 case lookupLevel numId lvl num of
575 case lookupLevel numId lvl num of
587− Just levelInfo -> return $ ListItem parstyle numId lvl levelInfo parparts
576+ Just levelInfo -> return $ ListItem parstyle numId lvl levelInfo parparts
588− Nothing -> throwError WrongElem
577+ Nothing -> throwError WrongElem
589elemToBodyPart ns element
578elemToBodyPart ns element
590 | isElem ns "w" "p" element = do
579 | isElem ns "w" "p" element = do
591− sty <- asks envParStyles
580+ sty <- asks envParStyles
592− let parstyle = elemToParagraphStyle ns element sty
581+ let parstyle = elemToParagraphStyle ns element sty
593− parparts <- mapD (elemToParPart ns) (elChildren element)
582+ parparts <- mapD (elemToParPart ns) (elChildren element)
583+ case pNumInfo parstyle of
584+ Just (numId, lvl) -> do
585+ num <- asks envNumbering
586+ case lookupLevel numId lvl num of
588+ return $ ListItem parstyle numId lvl levelInfo parparts
590+ throwError WrongElem
594− return $ Paragraph parstyle parparts
591+ Nothing -> return $ Paragraph parstyle parparts
595elemToBodyPart ns element
592elemToBodyPart ns element
596 | isElem ns "w" "tbl" element = do
593 | isElem ns "w" "tbl" element = do
597 let caption' = findChild (elemName ns "w" "tblPr") element
594 let caption' = findChild (elemName ns "w" "tblPr") element
@@ -771,6 +768,7 @@ elemToParagraphStyle ns element sty
771 Just _ -> True
768 Just _ -> True
772 Nothing -> False
769 Nothing -> False
773 , pHeading = getParStyleField headingLev sty style
770 , pHeading = getParStyleField headingLev sty style
771+ , pNumInfo = getParStyleField numInfo sty style
774 , pBlockQuote = getParStyleField isBlockQuote sty style
772 , pBlockQuote = getParStyleField isBlockQuote sty style
776elemToParagraphStyle _ _ _ = defaultParagraphStyle
774elemToParagraphStyle _ _ _ = defaultParagraphStyle
@@ -857,12 +855,26 @@ getBlockQuote ns element
857 , styleName `elem` blockQuoteStyleNames = Just True
855 , styleName `elem` blockQuoteStyleNames = Just True
858getBlockQuote _ _ = Nothing
856getBlockQuote _ _ = Nothing
858+getNumInfo :: NameSpaces -> Element -> Maybe (String, String)
859+getNumInfo ns element = do
860+ let numPr = findChild (elemName ns "w" "pPr") element >>=
861+ findChild (elemName ns "w" "numPr")
862+ lvl = fromMaybe "0" (numPr >>=
863+ findChild (elemName ns "w" "ilvl") >>=
864+ findAttr (elemName ns "w" "val"))
866+ findChild (elemName ns "w" "numId") >>=
867+ findAttr (elemName ns "w" "val")
860elemToParStyleData :: NameSpaces -> Element -> Maybe ParStyle -> ParStyleData
871elemToParStyleData :: NameSpaces -> Element -> Maybe ParStyle -> ParStyleData
861elemToParStyleData ns element parentStyle =
872elemToParStyleData ns element parentStyle =
862 ParStyleData
873 ParStyleData
864 headingLev = getHeaderLevel ns element
875 headingLev = getHeaderLevel ns element
865 , isBlockQuote = getBlockQuote ns element
876 , isBlockQuote = getBlockQuote ns element
877+ , numInfo = getNumInfo ns element
866 , psStyle = parentStyle
878 , psStyle = parentStyle