Ipelib

Public Types | Public Member Functions | List of all members
ipe::ImlParser Class Reference
Ipe Utilities

`#include <ipeiml.h>`

Inherits ipe::XmlParser.

Inherited by PdfStreamParser.

## Public Types
enum | Errors { ESuccess = 0 , EVersionTooOld , EVersionTooRecent , ESyntaxError }

## Public Member Functions
| ImlParser (DataSource &source)
int | parseDocument (Document &doc)
bool | parsePage (Page &page)
bool | parseView (Page &page, AttributeMap &map)
Object * | parseObject (String tag, Page *page=nullptr, int *currentLayer=nullptr)
Object * | parseObject (String tag, String &layer)
StyleSheet * | parseStyleSheet ()
bool | parseStyle (StyleSheet &sheet)
Page * | parsePageSelection ()
virtual Buffer | pdfStream (int objNum)
bool | parseBitmap ()
Public Member Functions inherited from ipe::XmlParser
| XmlParser (DataSource &source)
virtual | ~XmlParser ()
int | parsePosition () const
String | parseToTag ()
bool | parseAttributes (XmlAttributes &attr, bool qm=false)
bool | parsePCDATA (String tag, String &pcdata)
bool | isTagChar (int ch)
void | getChar ()
bool | eos ()
void | skipWhitespace ()

## Additional Inherited Members
Protected Member Functions inherited from ipe::XmlParser
String | parseToTagX ()
Protected Attributes inherited from ipe::XmlParser
DataSource & | iSource
String | iTopElement
int | iCh
int | iPos

## Detailed Description

XML Parser for Ipe documents and style sheets.

A recursive descent parser for the XML streams.

After experimenting with various XML parsing frameworks, this turned out to work best for Ipe.

## Member Enumeration Documentation

## ◆ Errors

enum ipe::ImlParser::Errors

Enumerator
ESuccess |
EVersionTooOld |
EVersionTooRecent |
ESyntaxError |

## Constructor & Destructor Documentation

## ◆ ImlParser()

ImlParser::ImlParser | ( | DataSource & | source | ) |
| explicit

## Member Function Documentation

## ◆ parseDocument()

int ImlParser::parseDocument | ( | Document & | doc | ) |

Read a complete document from IML stream.

Returns an error code.

References ipe::Document::cascade(), ESuccess, ESyntaxError, EVersionTooOld, EVersionTooRecent, ipe::XmlAttributes::has(), ipe::Document::SProperties::iAuthor, ipe::Document::SProperties::iCreated, ipe::Document::SProperties::iCreator, ipe::Document::SProperties::iFullScreen, ipe::Document::SProperties::iKeywords, ipe::Document::SProperties::iModified, ipe::Cascade::insert(), ipe::Document::SProperties::iNumberPages, ipe::IPELIB_VERSION, ipe::Document::SProperties::iPreamble, ipe::Document::SProperties::iSubject, ipe::Document::SProperties::iTexEngine, ipe::Document::SProperties::iTitle, ipe::Luatex, ipe::OLDEST_FILE_FORMAT, ipe::XmlParser::parseAttributes(), parseBitmap(), parsePage(), ipe::XmlParser::parsePCDATA(), parseStyle(), ipe::XmlParser::parseToTag(), ipe::Pdftex, ipe::Document::properties(), ipe::Document::push_back(), ipe::Document::setProperties(), and ipe::Xetex.

## ◆ parsePage()

bool ImlParser::parsePage | ( | Page & | page | ) |

Parse an Page.

On calling, stream must be just past `page`.

References ipe::Page::addLayer(), ipe::Page::Always, ipe::Page::count(), ipe::Page::countLayers(), ipe::Page::countViews(), ipe::String::empty(), ipe::ENotSelected, ipe::Lex::eos(), ipe::XmlAttributes::has(), ipe::Page::insert(), ipe::Page::insertView(), ipe::Page::isLocked(), ipe::Page::layer(), ipe::Page::Never, ipe::Lex::nextToken(), ipe::XmlParser::parseAttributes(), parseObject(), ipe::XmlParser::parsePCDATA(), ipe::XmlParser::parseToTag(), parseView(), ipe::Page::setActive(), ipe::Page::setEffect(), ipe::Page::setLayerData(), ipe::Page::setLocked(), ipe::Page::setMarked(), ipe::Page::setMarkedView(), ipe::Page::setNotes(), ipe::Page::setSection(), ipe::Page::setSnapping(), ipe::Page::setTitle(), ipe::Page::setViewMap(), ipe::Page::setViewName(), ipe::Page::setVisible(), ipe::Lex::skipWhitespace(), and ipe::XmlAttributes::slash().

Referenced by parseDocument(), and parsePageSelection().

## ◆ parseView()

bool ImlParser::parseView | ( | Page & | page,
|  | AttributeMap & | map
| ) |  |

Parse an attribute map.

On calling, stream must be before the first mapping element.

References ipe::AttributeMap::add(), ipe::Page::countViews(), ipe::EArrowSize, ipe::EColor, ipe::EDashStyle, ipe::String::empty(), ipe::EOpacity, ipe::EPen, ipe::ESymbol, ipe::ESymbolSize, ipe::Page::findLayer(), ipe::XmlAttributes::has(), ipe::XmlParser::parseAttributes(), ipe::XmlParser::parseToTag(), ipe::Page::setLayerMatrix(), and ipe::XmlAttributes::slash().

Referenced by parsePage().

## ◆ parseObject() [1/2]

Object * ImlParser::parseObject | ( | String | tag,
|  | Page * | page = `nullptr`,
|  | int * | currentLayer = `nullptr`
| ) |  |

parse an Object.

On calling, stream must be just past the tag.

References ipe::Page::countLayers(), ipe::String::empty(), ipe::Page::layer(), and parseObject().

Referenced by parseObject(), parsePage(), and parseStyle().

## ◆ parseObject() [2/2]

Object * ImlParser::parseObject | ( | String | tag,
|  | String & | layer
| ) |  |

parse an Object.

On calling, stream must be just past the tag.

References ipe::ObjectFactory::createImage(), ipe::ObjectFactory::createObject(), ipe::Lex::getInt(), ipe::XmlAttributes::has(), ipe::Bitmap::isNull(), ipe::XmlParser::parseAttributes(), parseObject(), ipe::XmlParser::parsePCDATA(), ipe::XmlParser::parseToTag(), ipe::Group::push_back(), and ipe::XmlAttributes::slash().

## ◆ parseStyleSheet()

StyleSheet * ImlParser::parseStyleSheet | ( |  | ) |

parse a complete style sheet.

On calling, stream must be before the 'ipestyle' tag. A <?xml> tag is allowed.

References ipe::XmlParser::parseAttributes(), parseStyle(), and ipe::XmlParser::parseToTag().

Referenced by ipe::StyleSheet::standard().

## ◆ parseStyle()

bool ImlParser::parseStyle | ( | StyleSheet & | sheet | ) |

Parse a style sheet.

On calling, stream must be just past the style tag.

References ipe::StyleSheet::add(), ipe::StyleSheet::addEffect(), ipe::StyleSheet::addGradient(), ipe::StyleSheet::addSymbol(), ipe::StyleSheet::addTiling(), ipe::Attribute::BLACK(), ipe::Gradient::Stop::color, ipe::Angle::Degrees(), ipe::EAlignBaseline, ipe::EAlignLeft, ipe::EAngleSize, ipe::EArrowSize, ipe::Gradient::EAxial, ipe::EColor, ipe::EDashStyle, ipe::EEvenOddRule, ipe::EGridSize, ipe::Reference::EHasFill, ipe::Reference::EHasPen, ipe::Reference::EHasSize, ipe::Reference::EHasStroke, ipe::ELabelStyle, ipe::String::empty(), ipe::EOpacity, ipe::Lex::eos(), ipe::EPen, ipe::Gradient::ERadial, ipe::ESymbolSize, ipe::ETextSize, ipe::ETextStretch, ipe::ETextStyle, ipe::ETransformationsRigidMotions, ipe::ETransformationsTranslations, ipe::EWindRule, ipe::Reference::flagsFromName(), ipe::Lex::getDouble(), ipe::Lex::getInt(), ipe::XmlAttributes::has(), ipe::Tiling::iAngle, ipe::TextPadding::iBottom, ipe::StyleSheet::TitleStyle::iColor, ipe::StyleSheet::PageNumberStyle::iColor, ipe::Layout::iCrop, ipe::StyleSheet::TitleStyle::iDefined, ipe::StyleSheet::PageNumberStyle::iDefined, ipe::Effect::iDuration, ipe::Effect::iEffect, ipe::Gradient::iExtend, ipe::Layout::iFrameSize, ipe::StyleSheet::TitleStyle::iHorizontalAlignment, ipe::StyleSheet::PageNumberStyle::iHorizontalAlignment, ipe::TextPadding::iLeft, ipe::Gradient::iMatrix, ipe::Layout::iOrigin, ipe::Layout::iPaperSize, ipe::Layout::iParagraphSkip, ipe::StyleSheet::TitleStyle::iPos, ipe::StyleSheet::PageNumberStyle::iPos, ipe::Gradient::iRadius, ipe::TextPadding::iRight, ipe::Attribute::isColor(), ipe::Fixed::isInteger(), ipe::StyleSheet::TitleStyle::iSize, ipe::StyleSheet::PageNumberStyle::iSize, ipe::Symbol::iSnap, ipe::Attribute::isNumber(), ipe::Attribute::isSymbolic(), ipe::Tiling::iStep, ipe::Gradient::iStops, ipe::StyleSheet::PageNumberStyle::iText, ipe::TextPadding::iTop, ipe::Symbol::iTransformations, ipe::Effect::iTransitionTime, ipe::Gradient::iType, ipe::Gradient::iV, ipe::StyleSheet::TitleStyle::iVerticalAlignment, ipe::StyleSheet::PageNumberStyle::iVerticalAlignment, ipe::Tiling::iWidth, ipe::Symbol::iXForm, ipe::Attribute::makeColor(), ipe::Attribute::makeDashStyle(), ipe::Text::makeHAlign(), ipe::Attribute::makeScalar(), ipe::Attribute::makeTextSize(), ipe::Text::makeVAlign(), ipe::Attribute::NORMAL(), ipe::Attribute::number(), ipe::Gradient::Stop::offset, ipe::XmlParser::parseAttributes(), parseBitmap(), parseObject(), ipe::XmlParser::parsePCDATA(), ipe::XmlParser::parseToTag(), ipe::StyleSheet::setFillRule(), ipe::StyleSheet::setLayout(), ipe::StyleSheet::setLineCap(), ipe::StyleSheet::setLineJoin(), ipe::StyleSheet::setName(), ipe::StyleSheet::setPageNumberStyle(), ipe::StyleSheet::setPreamble(), ipe::StyleSheet::setTextPadding(), ipe::StyleSheet::setTitleStyle(), ipe::size(), ipe::Lex::skipWhitespace(), ipe::XmlAttributes::slash(), ipe::Vector::x, and ipe::Vector::y.

Referenced by parseDocument(), and parseStyleSheet().

## ◆ parsePageSelection()

Page * ImlParser::parsePageSelection | ( |  | ) |

parse an `` <ipepage> element (used on clipboard).

References ipe::XmlParser::parseAttributes(), parseBitmap(), parsePage(), and ipe::XmlParser::parseToTag().

## ◆ pdfStream()

Buffer ImlParser::pdfStream | ( | int | objNum | ) |
| virtual

XML contents can refer to data in PDF.

If the XML stream is embedded in a PDF file, XML contents can refer to PDF objects. A derived parser must implement this method to access PDF data.

It is assumed that PDF object objNum is a stream. Its contents (uncompressed!) is returned in a buffer.

Referenced by parseBitmap().

## ◆ parseBitmap()

bool ImlParser::parseBitmap | ( |  | ) |

Parse an Bitmap.

On calling, stream must be just past `bitmap`.

References ipe::Lex::eos(), ipe::Lex::getInt(), ipe::XmlAttributes::has(), ipe::XmlParser::parseAttributes(), ipe::XmlParser::parsePCDATA(), pdfStream(), ipe::Lex::skipWhitespace(), and ipe::XmlAttributes::slash().

Referenced by parseDocument(), parsePageSelection(), and parseStyle().

The documentation for this class was generated from the following files:

- ipeiml.h
- ipeiml.cpp