ipe::Document Class Reference
Ipe Document

`#include <ipedoc.h>`

## Classes

struct | SProperties

## Public Types

enum | TFormat { EXml, EPdf, EEps, EIpe5, EUnknown }
enum | { ESaveNormal = 0, EExport = 1, ENoZip = 2, EMarkedView = 4 }
enum | LoadErrors { EVersionTooOld = -1, EVersionTooRecent = -2, EFileOpenError = -3, ENotAnIpeFile = -4 }
enum | { ErrNone, ErrNoText, ErrNoDir, ErrWritingSource, ErrOldPdfLatex, ErrRunLatex, ErrLatex, ErrLatexOutput }

## Public Member Functions

| Document ()
| Document (const Document &rhs)
Document & | operator= (const Document &rhs)=delete
| ~Document ()
bool | save (TellStream &stream, TFormat format, uint flags) const
bool | save (const char *fname, TFormat format, uint flags) const
bool | exportPages (const char *fname, uint flags, int fromPage, int toPage) const
bool | exportView (const char *fname, TFormat format, uint flags, int pno, int vno) const
void | saveAsXml (Stream &stream, bool usePdfBitmaps=false) const
int | countPages () const
int | countTotalViews () const
const Page * | page (int no) const
Page * | page (int no)
Page * | set (int no, Page *page)
void | insert (int no, Page *page)
void | push_back (Page *page)
Page * | remove (int no)
SProperties | properties () const
void | setProperties (const SProperties &info)
Cascade * | cascade ()
const Cascade * | cascade () const
Cascade * | replaceCascade (Cascade *cascade)
void | setResources (PdfResources *resources)
const PdfResources * | resources () const noexcept
void | findBitmaps (BitmapFinder &bm) const
bool | checkStyle (AttributeSeq &seq) const
int | runLatex (String &logFile)
int | runLatex ()

## Static Public Member Functions

static TFormat | fileFormat (DataSource &source)
static TFormat | formatFromFilename (String fn)
static Document * | load (DataSource &source, TFormat format, int &reason)
static Document * | load (const char *fname, int &reason)
static Document * | loadWithErrorReport (const char *fname)

## Detailed Description

The model for an Ipe document.

The Document class represents the contents of an Ipe document, and all the methods necessary to load, save, and modify it.

## Member Enumeration Documentation

enum ipe::Document::TFormat

There are several Ipe document formats.

Enumerator
EXml | Save as XML.
EPdf | Save as PDF.
EEps | Encapsulated Postscript (loading only)
EIpe5 | Ancient Ipe format.
EUnknown | Unknown file format.

anonymous enum

Options for saving Ipe documents (to PDF and Postscript)

Enumerator
ESaveNormal | Nothing special.
EExport | Don't include Ipe markup.
ENoZip | Do not compress streams.
EMarkedView | Create marked views only.

enum ipe::Document::LoadErrors

Errors that can happen while loading documents.

Enumerator
EVersionTooOld | The version of the file is too old.
EVersionTooRecent | The file version is newer than this Ipelib.
EFileOpenError | Error opening the file.
ENotAnIpeFile | The file was not created by Ipe.

anonymous enum

Error codes returned by RunLatex.

Enumerator
ErrNone |
ErrNoText |
ErrNoDir |
ErrWritingSource |
ErrOldPdfLatex |
ErrRunLatex |
ErrLatex |
ErrLatexOutput |

## Constructor & Destructor Documentation

Document::Document | ( |  | ) |

Construct an empty document for filling by a client.

As constructed, it has no pages, A4 media, and only the standard style sheet.

References ipe::Cascade::insert(), and ipe::StyleSheet::standard().

Referenced by formatFromFilename().

Document::Document | ( | const Document & | rhs | ) |

Copy constructor.

References countPages(), ipe::DataSource::getChar(), and page().

Document::~Document | ( |  | ) |

Destructor.

References countPages(), and page().

## Member Function Documentation

Document& ipe::Document::operator= | ( | const Document & | rhs | ) |

delete

Document::TFormat Document::fileFormat | ( | DataSource & | source | ) |

static

Determine format of file in source.

References EEps, EIpe5, EPdf, EUnknown, EXml, and ipe::String::substr().

Referenced by load().

Document::TFormat Document::formatFromFilename | ( | String | fn | ) |

static

Determine format of file from filename fn.

References ipe::Buffer::data(), ipe::PdfDict::deflated(), ipe::PdfObj::dict(), Document(), EEps, EFileOpenError, ENotAnIpeFile, EPdf, ipe::ImlParser::ESyntaxError, EUnknown, EXml, ipe::PdfDict::get(), ipe::A85Source::getChar(), ipe::DataSource::getChar(), ipe::PdfObj::name(), ipe::PdfFile::object(), ipe::PdfFile::parse(), ipe::ImlParser::parseDocument(), ipe::XmlParser::parsePosition(), ipe::String::right(), ipe::String::size(), ipe::Buffer::size(), ipe::PdfDict::stream(), ipe::String::substr(), and ipe::PdfName::value().

Document * Document::load | ( | DataSource & | source,
|  | TFormat | format,
|  | int & | reason
| ) |  |

static

Construct a document from an input stream.

Returns 0 if the stream couldn't be parsed, and a reason explaining that in reason. If reason is positive, it is a file (stream) offset where parsing failed. If reason is negative, it is an error code, see Document::LoadErrors.

References EEps, EIpe5, ENotAnIpeFile, EPdf, EVersionTooOld, and EXml.

Referenced by load(), and loadWithErrorReport().

Document * Document::load | ( | const char * | fname,
|  | int & | reason
| ) |  |

static

References EFileOpenError, fileFormat(), ipe::Platform::fopen(), and load().

Document * Document::loadWithErrorReport | ( | const char * | fname | ) |

static

References EFileOpenError, ENotAnIpeFile, EVersionTooOld, EVersionTooRecent, and load().

bool Document::save | ( | TellStream & | stream,
|  | TFormat | format,
|  | uint | flags
| ) |  | const

Save in a stream.

Returns true if sucessful.

References ipe::DeflateStream::close(), ipe::PdfWriter::createBookmarks(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), ipe::PdfWriter::createXmlStream(), EExport, EMarkedView, ENoZip, EPdf, EXml, and saveAsXml().

Referenced by save().

bool Document::save | ( | const char * | fname,
|  | TFormat | format,
|  | uint | flags
| ) |  | const

References ipe::Platform::fopen(), and save().

bool Document::exportPages | ( | const char * | fname,
|  | uint | flags,
|  | int | fromPage,
|  | int | toPage
| ) |  | const

Export a range of pages to PDF.

References ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), EMarkedView, ENoZip, and ipe::Platform::fopen().

bool Document::exportView | ( | const char * | fname,
|  | TFormat | format,
|  | uint | flags,
|  | int | pno,
|  | int | vno
| ) |  | const

Export a single view to PDF.

References ipe::PdfWriter::createPageView(), ipe::PdfWriter::createTrailer(), EMarkedView, ENoZip, EPdf, and ipe::Platform::fopen().

void Document::saveAsXml | ( | Stream & | stream,
|  | bool | usePdfBitmaps = `false`
| ) |  | const

Save in XML format into an Stream.

References countPages(), ipe::Default, ipe::FILE_FORMAT, findBitmaps(), ipe::BitmapFinder::iBitmaps, ipe::Luatex, ipe::Bitmap::objNum(), page(), ipe::Pdftex, ipe::Stream::putXmlString(), ipe::Page::saveAsXml(), ipe::Bitmap::saveAsXml(), and ipe::Xetex.

Referenced by save().

int ipe::Document::countPages | ( |  | ) | const

inline

Return number of pages of document.

References countTotalViews().

Referenced by checkStyle(), countTotalViews(), Document(), findBitmaps(), ipe::PageSelector::PageSelector(), runLatex(), saveAsXml(), and ~Document().

int Document::countTotalViews | ( |  | ) | const

Return total number of views in all pages.

References countPages(), ipe::Page::countViews(), and page().

Referenced by countPages().

const Page* ipe::Document::page | ( | int | no | ) | const

inline

Return page (const version).

The first page is no 0.

Referenced by checkStyle(), countTotalViews(), Document(), findBitmaps(), insert(), page(), ipe::PageSelector::PageSelector(), runLatex(), saveAsXml(), set(), and ~Document().

Page* ipe::Document::page | ( | int | no | ) |

inline

Return page.

The first page is no 0.

References insert(), page(), and push_back().

Page * Document::set | ( | int | no,
|  | Page * | page
| ) |  |

Replace page.

Returns the original page.

References page().

void Document::insert | ( | int | no,
|  | Page * | page
| ) |  |

Insert a new page.

The page is inserted at index no.

References page().

Referenced by page().

void Document::push_back | ( | Page * | page | ) |

Append a new page.

Referenced by page(), and ipe::ImlParser::parseDocument().

Page * Document::remove | ( | int | no | ) |

Remove a page.

Returns the page that has been removed.

SProperties ipe::Document::properties | ( |  | ) | const

inline

Return document properties.

References setProperties().

Referenced by ipe::ImlParser::parseDocument(), and runLatex().

void Document::setProperties | ( | const SProperties & | info | ) |

Set document properties.

Referenced by ipe::ImlParser::parseDocument(), and properties().

Cascade* ipe::Document::cascade | ( |  | ) |

inline

Return stylesheet cascade.

Referenced by cascade(), checkStyle(), ipe::ImlParser::parseDocument(), ipe::Thumbnail::render(), runLatex(), ipe::Thumbnail::saveRender(), and ipe::Thumbnail::Thumbnail().

const Cascade* ipe::Document::cascade | ( |  | ) | const

inline

Return stylesheet cascade (const version).

References cascade(), replaceCascade(), resources(), and setResources().

Cascade * Document::replaceCascade | ( | Cascade * | sheets | ) |

Replace the entire style sheet cascade.

Takes ownership of cascade, and returns the original cascade.

Referenced by cascade().

void Document::setResources | ( | PdfResources * | resources | ) |

Update the PDF resources (after running latex).

Takes ownership.

References ipe::ImlParser::parseStyleSheet(), and resources().

Referenced by cascade(), and runLatex().

const PdfResources* ipe::Document::resources | ( |  | ) | const

inline noexcept

Return the current PDF resources.

References checkStyle(), and findBitmaps().

Referenced by cascade(), runLatex(), setResources(), and ipe::Thumbnail::Thumbnail().

void Document::findBitmaps | ( | BitmapFinder & | bm | ) | const

Create a list of all bitmaps in the document.

References ipe::Object::accept(), countPages(), ipe::ESymbol, ipe::BitmapFinder::iBitmaps, ipe::Symbol::iObject, page(), and ipe::BitmapFinder::scanPage().

Referenced by resources(), and saveAsXml().

bool Document::checkStyle | ( | AttributeSeq & | seq | ) | const

Check all symbolic attributes in the document.

This function verifies that all symbolic attributes in the document are defined in the style sheet. It appends to seq all symbolic attributes (in no particular order, but without duplicates) that are NOT defined.

Returns `true` if there are no undefined symbolic attributes in the document.

References cascade(), ipe::Object::checkStyle(), ipe::Page::count(), countPages(), ipe::Page::object(), and page().

Referenced by resources().

int Document::runLatex | ( | String & | logFile | ) |

Run PdfLatex or Xelatex.

References ipe::Latex::addPageNumber(), ipe::Cascade::allNames(), cascade(), countPages(), ipe::Page::countViews(), ipe::Latex::createLatexSource(), ipe::String::empty(), ErrLatex, ErrLatexOutput, ErrNoDir, ErrNone, ErrNoText, ErrRunLatex, ErrWritingSource, ipe::ESymbol, ipe::String::find(), ipe::Cascade::findSymbol(), ipe::Platform::fopen(), ipe::Symbol::iObject, ipe::Platform::latexDirectory(), ipe::String::left(), page(), properties(), ipe::Platform::readFile(), ipe::Latex::readPdf(), resources(), ipe::Platform::runLatex(), ipe::Latex::scanObject(), ipe::Latex::scanPage(), setResources(), ipe::PdfResources::show(), ipe::String::substr(), ipe::Latex::takeResources(), ipe::Latex::updateTextObjects(), and ipe::String::z().

int Document::runLatex | ( |  | ) |

Run Pdflatex (suitable for console applications)

Success/error is reported on stderr.

References ErrLatex, ErrLatexOutput, ErrNoDir, ErrNone, ErrNoText, ErrOldPdfLatex, ErrRunLatex, and ErrWritingSource.

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

- ipedoc.h
- ipedoc.cpp