LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/cdr/src/lib - CMXDocument.cpp (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 35 0.0 %
Date: 2012-12-17 Functions: 0 5 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             : /* libcdr
       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 Fridrich Strba <fridrich.strba@bluewin.ch>
      17             :  *
      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             : #include <string>
      31             : #include <string.h>
      32             : #include "CMXDocument.h"
      33             : #include "CDRDocumentStructure.h"
      34             : #include "CMXParser.h"
      35             : #include "CDRSVGGenerator.h"
      36             : #include "CDRContentCollector.h"
      37             : #include "CDRStylesCollector.h"
      38             : #include "CDRZipStream.h"
      39             : #include "libcdr_utils.h"
      40             : 
      41             : /**
      42             : Analyzes the content of an input stream to see if it can be parsed
      43             : \param input The input stream
      44             : \return A value that indicates whether the content from the input
      45             : stream is a Corel Draw Document that libcdr is able to parse
      46             : */
      47           0 : bool libcdr::CMXDocument::isSupported(WPXInputStream *input)
      48             : {
      49           0 :   input->seek(0, WPX_SEEK_SET);
      50           0 :   unsigned riff = readU32(input);
      51           0 :   if (riff != FOURCC_RIFF && riff != FOURCC_RIFX)
      52           0 :     return false;
      53           0 :   input->seek(4, WPX_SEEK_CUR);
      54           0 :   char signature_c = (char)readU8(input);
      55           0 :   if (signature_c != 'C' && signature_c != 'c')
      56           0 :     return false;
      57           0 :   char signature_d = (char)readU8(input);
      58           0 :   if (signature_d != 'M' && signature_d != 'm')
      59           0 :     return false;
      60           0 :   char signature_r = (char)readU8(input);
      61           0 :   if (signature_r != 'X' && signature_r != 'x')
      62           0 :     return false;
      63           0 :   return true;
      64             : }
      65             : 
      66             : /**
      67             : Parses the input stream content. It will make callbacks to the functions provided by a
      68             : CDRPaintInterface class implementation when needed. This is often commonly called the
      69             : 'main parsing routine'.
      70             : \param input The input stream
      71             : \param painter A CDRPainterInterface implementation
      72             : \return A value that indicates whether the parsing was successful
      73             : */
      74           0 : bool libcdr::CMXDocument::parse(::WPXInputStream *input, libwpg::WPGPaintInterface *painter)
      75             : {
      76           0 :   input->seek(0, WPX_SEEK_SET);
      77           0 :   CDRParserState ps;
      78           0 :   CDRStylesCollector stylesCollector(ps);
      79           0 :   CMXParser stylesParser(&stylesCollector);
      80           0 :   bool retVal = stylesParser.parseRecords(input);
      81           0 :   if (ps.m_pages.empty())
      82           0 :     retVal = false;
      83           0 :   if (retVal)
      84             :   {
      85           0 :     input->seek(0, WPX_SEEK_SET);
      86           0 :     CDRContentCollector contentCollector(ps, painter);
      87           0 :     CMXParser contentParser(&contentCollector);
      88           0 :     retVal = contentParser.parseRecords(input);
      89             :   }
      90           0 :   return retVal;
      91             : }
      92             : 
      93             : /**
      94             : Parses the input stream content and generates a valid Scalable Vector Graphics
      95             : Provided as a convenience function for applications that support SVG internally.
      96             : \param input The input stream
      97             : \param output The output string whose content is the resulting SVG
      98             : \return A value that indicates whether the SVG generation was successful.
      99             : */
     100           0 : bool libcdr::CMXDocument::generateSVG(::WPXInputStream *input, libcdr::CDRStringVector &output)
     101             : {
     102           0 :   libcdr::CDRSVGGenerator generator(output);
     103           0 :   bool result = libcdr::CMXDocument::parse(input, &generator);
     104           0 :   return result;
     105           0 : }
     106             : 
     107             : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */

Generated by: LCOV version 1.10