LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/mspub/src/lib - MSPUBParser.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 7 0.0 %
Date: 2012-12-17 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* libmspub
       3             :  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  * Copyright (C) 2012 Brennan Vincent <brennanv@email.arizona.edu>
      17             :  * Copyright (C) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
      18             :  *
      19             :  * All Rights Reserved.
      20             :  *
      21             :  * For minor contributions see the git repository.
      22             :  *
      23             :  * Alternatively, the contents of this file may be used under the terms of
      24             :  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
      25             :  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
      26             :  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
      27             :  * instead of those above.
      28             :  */
      29             : 
      30             : #ifndef __MSPUBPARSER_H__
      31             : #define __MSPUBPARSER_H__
      32             : 
      33             : #include <map>
      34             : #include <set>
      35             : #include <vector>
      36             : #include <memory>
      37             : 
      38             : #include <boost/shared_ptr.hpp>
      39             : #include <boost/optional.hpp>
      40             : 
      41             : #include <libwpd/libwpd.h>
      42             : #include <libwpg/libwpg.h>
      43             : 
      44             : #include "MSPUBTypes.h"
      45             : #include "Fill.h"
      46             : #include "Coordinate.h"
      47             : #include "PolygonUtils.h"
      48             : 
      49             : class WPXInputStream;
      50             : 
      51             : namespace libmspub
      52             : {
      53             : class MSPUBCollector;
      54             : class FindBySeqNum
      55             : {
      56             :   unsigned seqNum;
      57             : public:
      58             :   FindBySeqNum(unsigned sn) : seqNum(sn) { }
      59             :   bool operator()(const libmspub::ContentChunkReference &ref)
      60             :   {
      61             :     return ref.seqNum == seqNum;
      62             :   }
      63             : };
      64             : 
      65             : class FindByParentSeqNum
      66             : {
      67             :   unsigned seqNum;
      68             : public:
      69             :   FindByParentSeqNum(unsigned sn) : seqNum(sn) { }
      70             :   bool operator()(const libmspub::ContentChunkReference &ref)
      71             :   {
      72             :     return ref.parentSeqNum == seqNum;
      73             :   }
      74             : };
      75             : 
      76           0 : struct FOPTValues
      77             : {
      78             :   std::map<unsigned short, unsigned> m_scalarValues;
      79             :   std::map<unsigned short, std::vector<unsigned char> > m_complexValues;
      80           0 :   FOPTValues() : m_scalarValues(), m_complexValues()
      81             :   {
      82           0 :   }
      83             : };
      84             : 
      85             : class MSPUBParser
      86             : {
      87             : public:
      88             :   explicit MSPUBParser(WPXInputStream *input, MSPUBCollector *collector);
      89             :   virtual ~MSPUBParser();
      90             :   virtual bool parse();
      91             : protected:
      92             :   virtual unsigned getColorIndexByQuillEntry(unsigned entry);
      93             : 
      94           0 :   struct TextSpanReference
      95             :   {
      96           0 :     TextSpanReference(unsigned short f, unsigned short l, CharacterStyle cs) : first(f), last(l), charStyle(cs) { }
      97             :     unsigned short first;
      98             :     unsigned short last;
      99             :     CharacterStyle charStyle;
     100             :   };
     101             : 
     102           0 :   struct TextParagraphReference
     103             :   {
     104           0 :     TextParagraphReference(unsigned short f, unsigned short l, ParagraphStyle ps) : first(f), last(l), paraStyle(ps) { }
     105             :     unsigned short first;
     106             :     unsigned short last;
     107             :     ParagraphStyle paraStyle;
     108             :   };
     109             : 
     110             :   typedef std::vector<ContentChunkReference>::const_iterator ccr_iterator_t;
     111             : 
     112             :   MSPUBParser();
     113             :   MSPUBParser(const MSPUBParser &);
     114             :   MSPUBParser &operator=(const MSPUBParser &);
     115             :   virtual bool parseContents(WPXInputStream *input);
     116             :   bool parseQuill(WPXInputStream *input);
     117             :   bool parseEscher(WPXInputStream *input);
     118             :   bool parseEscherDelay(WPXInputStream *input);
     119             : 
     120             :   MSPUBBlockInfo parseBlock(WPXInputStream *input, bool skipHierarchicalData = false);
     121             :   EscherContainerInfo parseEscherContainer(WPXInputStream *input);
     122             : 
     123             :   bool parseContentChunkReference(WPXInputStream *input, MSPUBBlockInfo block);
     124             :   QuillChunkReference parseQuillChunkReference(WPXInputStream *input);
     125             :   bool parseDocumentChunk(WPXInputStream *input, const ContentChunkReference &chunk);
     126             :   bool parsePageChunk(WPXInputStream *input, const ContentChunkReference &chunk);
     127             :   bool parsePaletteChunk(WPXInputStream *input, const ContentChunkReference &chunk);
     128             :   bool parsePageShapeList(WPXInputStream *input, MSPUBBlockInfo block, unsigned pageSeqNum);
     129             :   bool parseShape(WPXInputStream *input, const ContentChunkReference &chunk);
     130             :   bool parseBorderArtChunk(WPXInputStream *input,
     131             :                            const ContentChunkReference &chunk);
     132             :   bool parseFontChunk(WPXInputStream *input,
     133             :                       const ContentChunkReference &chunk);
     134             :   void parsePaletteEntry(WPXInputStream *input, MSPUBBlockInfo block);
     135             :   void parseColors(WPXInputStream *input, const QuillChunkReference &chunk);
     136             :   void parseFonts(WPXInputStream *input, const QuillChunkReference &chunk);
     137             :   void parseDefaultStyle(WPXInputStream *input, const QuillChunkReference &chunk);
     138             :   void parseShapeGroup(WPXInputStream *input, const EscherContainerInfo &spgr, Coordinate parentCoordinateSystem, Coordinate parentGroupAbsoluteCoord);
     139             :   void skipBlock(WPXInputStream *input, MSPUBBlockInfo block);
     140             :   void parseEscherShape(WPXInputStream *input, const EscherContainerInfo &sp, Coordinate &parentCoordinateSystem, Coordinate &parentGroupAbsoluteCoord);
     141             :   bool findEscherContainer(WPXInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, unsigned short type);
     142             :   bool findEscherContainerWithTypeInSet(WPXInputStream *input, const EscherContainerInfo &parent, EscherContainerInfo &out, std::set<unsigned short> types);
     143             :   std::map<unsigned short, unsigned> extractEscherValues(WPXInputStream *input, const EscherContainerInfo &record);
     144             :   FOPTValues extractFOPTValues(WPXInputStream *input,
     145             :                                const libmspub::EscherContainerInfo &record);
     146             :   std::vector<TextSpanReference> parseCharacterStyles(WPXInputStream *input, const QuillChunkReference &chunk);
     147             :   std::vector<TextParagraphReference> parseParagraphStyles(WPXInputStream *input, const QuillChunkReference &chunk);
     148             :   std::vector<Calculation> parseGuides(const std::vector<unsigned char>
     149             :                                        &guideData);
     150             :   std::vector<Vertex> parseVertices(const std::vector<unsigned char>
     151             :                                     &vertexData);
     152             :   std::vector<unsigned> parseTableCellDefinitions(WPXInputStream *input,
     153             :       const QuillChunkReference &chunk);
     154             :   std::vector<unsigned short> parseSegments(
     155             :     const std::vector<unsigned char> &segmentData);
     156             :   DynamicCustomShape getDynamicCustomShape(
     157             :     const std::vector<unsigned char> &vertexData,
     158             :     const std::vector<unsigned char> &segmentData,
     159             :     const std::vector<unsigned char> &guideData,
     160             :     unsigned geoWidth, unsigned geoHeight);
     161             :   int getColorIndex(WPXInputStream *input, const MSPUBBlockInfo &info);
     162             :   unsigned getFontIndex(WPXInputStream *input, const MSPUBBlockInfo &info);
     163             :   CharacterStyle getCharacterStyle(WPXInputStream *input);
     164             :   ParagraphStyle getParagraphStyle(WPXInputStream *input);
     165             :   boost::shared_ptr<Fill> getNewFill(const std::map<unsigned short, unsigned> &foptValues, bool &skipIfNotBg);
     166             : 
     167             :   WPXInputStream *m_input;
     168             :   MSPUBCollector *m_collector;
     169             :   std::vector<MSPUBBlockInfo> m_blockInfo;
     170             :   std::vector<ContentChunkReference> m_contentChunks;
     171             :   std::vector<unsigned> m_cellsChunkIndices;
     172             :   std::vector<unsigned> m_pageChunkIndices;
     173             :   std::vector<unsigned> m_shapeChunkIndices;
     174             :   std::vector<unsigned> m_paletteChunkIndices;
     175             :   std::vector<unsigned> m_borderArtChunkIndices;
     176             :   std::vector<unsigned> m_fontChunkIndices;
     177             :   std::vector<unsigned> m_unknownChunkIndices;
     178             :   boost::optional<unsigned> m_documentChunkIndex;
     179             :   int m_lastSeenSeqNum;
     180             :   unsigned m_lastAddedImage;
     181             :   std::vector<int> m_alternateShapeSeqNums;
     182             :   std::vector<int> m_escherDelayIndices;
     183             : 
     184             :   static short getBlockDataLength(unsigned type);
     185             :   static bool isBlockDataString(unsigned type);
     186             :   static PageType getPageTypeBySeqNum(unsigned seqNum);
     187             :   static unsigned getEscherElementTailLength(unsigned short type);
     188             :   static unsigned getEscherElementAdditionalHeaderLength(unsigned short type);
     189             :   static ImgType imgTypeByBlipType(unsigned short type);
     190             :   static int getStartOffset(ImgType type, unsigned short initial);
     191             :   static bool lineExistsByFlagPointer(unsigned *flags,
     192             :                                       unsigned *geomFlags = NULL);
     193             : };
     194             : 
     195             : } // namespace libmspub
     196             : 
     197             : #endif //  __MSPUBRAPHICS_H__
     198             : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated by: LCOV version 1.10