ipe::Document Class Reference
Ipe Document

`#include <ipedoc.h>`

## Classes

struct | SProperties

## Public Types

enum | LoadErrors { EVersionTooOld = -1 , EVersionTooRecent = -2 , EFileOpenError = -3 , ENotAnIpeFile = -4 }
enum | { ErrNone , ErrNoText , ErrNoDir , ErrWritingSource , ErrRunLatex , ErrLatex , ErrLatexOutput }

## Public Member Functions

| Document ()
| Document (const Document &rhs)
Document & | operator= (const Document &rhs)=delete
| ~Document ()
bool | save (TellStream &stream, FileFormat format, uint32_t flags) const
bool | save (const char *fname, FileFormat format, uint32_t flags) const
bool | exportPages (const char *fname, uint32_t flags, int fromPage, int toPage) const
bool | exportView (const char *fname, FileFormat format, uint32_t 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)
int | findPage (String nameOrNumber) const
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 docname, String &logFile)
int | runLatex (String docname)
int | runLatexAsync (String docname, String &texLog, Latex **pConverter)
int | completeLatexRun (Latex *converter)

## Static Public Member Functions

static FileFormat | fileFormat (DataSource &source)
static FileFormat | formatFromFilename (String fn)
static Document * | load (DataSource &source, FileFormat 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

## LoadErrors

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

anonymous enum

Error codes returned by RunLatex.

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

## Constructor & Destructor Documentation

## Document() [1/2]

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().

## Document() [2/2]

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

Copy constructor.

References countPages(), and page().

## ~Document()

Document::~Document | ( |  | ) |

Destructor.

References countPages(), and page().

## Member Function Documentation

## operator=()

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

delete

## fileFormat()

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

static

Determine format of file in source.

References ipe::Pdf, ipe::String::substr(), ipe::Unknown, and ipe::Xml.

Referenced by load().

## formatFromFilename()

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

static

Determine format of file from filename fn.

References ipe::Pdf, ipe::String::right(), ipe::String::size(), ipe::Unknown, and ipe::Xml.

## load() [1/2]

Document * Document::load | ( | DataSource & | source,
|  | FileFormat | 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 ENotAnIpeFile, ipe::Pdf, and ipe::Xml.

Referenced by load(), and loadWithErrorReport().

## load() [2/2]

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

static

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

## loadWithErrorReport()

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

static

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

## save() [1/2]

bool Document::save | ( | TellStream & | stream,
|  | FileFormat | format,
|  | uint32_t | flags
| ) |  | const

Save in a stream.

Returns true if sucessful.

References ipe::DeflateStream::close(), ipe::PdfWriter::createBookmarks(), ipe::PdfWriter::createNamedDests(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), ipe::PdfWriter::createXmlStream(), ipe::SaveFlag::Export, ipe::SaveFlag::NoZip, ipe::Pdf, saveAsXml(), and ipe::Xml.

Referenced by save().

## save() [2/2]

bool Document::save | ( | const char * | fname,
|  | FileFormat | format,
|  | uint32_t | flags
| ) |  | const

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

## exportPages()

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

Export a range of pages to PDF.

References ipe::PdfWriter::createPages(), ipe::PdfWriter::createTrailer(), ipe::Platform::fopen(), and ipe::SaveFlag::NoZip.

## exportView()

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

Export a single view to PDF.

References ipe::PdfWriter::createPageView(), ipe::PdfWriter::createTrailer(), ipe::Platform::fopen(), ipe::SaveFlag::NoZip, and ipe::Pdf.

## saveAsXml()

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

Save in XML format into an Stream.

References countPages(), ipe::Default, ipe::String::empty(), ipe::FILE_FORMAT, findBitmaps(), ipe::Document::SProperties::iAuthor, ipe::BitmapFinder::iBitmaps, ipe::Document::SProperties::iCreated, ipe::Document::SProperties::iCreator, ipe::Document::SProperties::iFullScreen, ipe::Document::SProperties::iKeywords, ipe::Document::SProperties::iModified, ipe::Document::SProperties::iNumberPages, ipe::Document::SProperties::iPreamble, ipe::Document::SProperties::iSubject, ipe::Document::SProperties::iTexEngine, ipe::Document::SProperties::iTitle, ipe::Luatex, ipe::Bitmap::objNum(), page(), ipe::Pdftex, ipe::Stream::putXmlString(), ipe::Page::saveAsXml(), ipe::Cascade::saveAsXml(), ipe::Bitmap::saveAsXml(), ipe::String::size(), and ipe::Xetex.

Referenced by save().

## countPages()

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

inline

Return number of pages of document.

Referenced by checkStyle(), countTotalViews(), ipe::PdfWriter::createTrailer(), Document(), findBitmaps(), findPage(), ipe::PdfWriter::PdfWriter(), runLatexAsync(), saveAsXml(), and ~Document().

## countTotalViews()

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

Return total number of views in all pages.

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

Referenced by ipe::PdfWriter::createTrailer().

## page() [1/2]

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

inline

Return page (const version).

The first page is no 0.

Referenced by checkStyle(), countTotalViews(), ipe::PdfWriter::createBookmarks(), ipe::PdfWriter::createNamedDests(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createPageView(), ipe::PdfWriter::createTrailer(), Document(), findBitmaps(), findPage(), insert(), push_back(), runLatexAsync(), saveAsXml(), set(), and ~Document().

## page() [2/2]

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

inline

Return page.

The first page is no 0.

## findPage()

int Document::findPage | ( | String | s | ) | const

Return page index given a section title or page number.

Input page numbers are 1-based strings. Returns -1 if page not found.

References countPages(), ipe::String::empty(), ipe::Lex::getInt(), page(), and ipe::Page::section().

## set()

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

Replace page.

Returns the original page.

References page().

## insert()

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

Insert a new page.

The page is inserted at index no.

References page().

## push_back()

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

Append a new page.

References page().

Referenced by ipe::ImlParser::parseDocument().

## remove()

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

Remove a page.

Returns the page that has been removed.

## properties()

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

inline

Return document properties.

Referenced by ipe::PdfWriter::createTrailer(), ipe::ImlParser::parseDocument(), and runLatexAsync().

## setProperties()

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

Set document properties.

Referenced by ipe::ImlParser::parseDocument().

## cascade() [1/2]

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

inline

Return stylesheet cascade.

Referenced by checkStyle(), ipe::PdfWriter::createPageView(), ipe::ImlParser::parseDocument(), ipe::PdfWriter::PdfWriter(), ipe::Thumbnail::render(), runLatexAsync(), ipe::Thumbnail::saveRender(), and ipe::Thumbnail::Thumbnail().

## cascade() [2/2]

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

inline

Return stylesheet cascade (const version).

## replaceCascade()

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

Replace the entire style sheet cascade.

Takes ownership of cascade, and returns the original cascade.

## setResources()

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

Update the PDF resources (after running latex).

Takes ownership.

References resources().

Referenced by completeLatexRun().

## resources()

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

inline noexcept

Return the current PDF resources.

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

## findBitmaps()

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

Create a list of all bitmaps in the document.

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

Referenced by ipe::PdfWriter::PdfWriter(), and saveAsXml().

## checkStyle()

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().

## runLatex() [1/2]

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

References completeLatexRun(), and runLatexAsync().

Referenced by runLatex().

## runLatex() [2/2]

int Document::runLatex | ( | String | docname | ) |

Run Pdflatex (suitable for console applications)

Success/error is reported on stderr.

References ErrLatex, ErrLatexOutput, ErrNoDir, ErrNone, ErrNoText, ErrRunLatex, ErrWritingSource, and runLatex().

## runLatexAsync()

int Document::runLatexAsync | ( | String | docname,
|  | String & | texLog,
|  | Latex ** | pConverter
| ) |  |

Run PdfLatex or Xelatex.

References ipe::Cascade::allNames(), cascade(), countPages(), ipe::Page::countViews(), ipe::String::empty(), ErrLatex, ErrLatexOutput, ErrNoDir, ErrNone, ErrNoText, ErrRunLatex, ErrWritingSource, ipe::ESymbol, ipe::String::find(), ipe::Cascade::findSymbol(), ipe::Platform::fopen(), ipe::String::hasPrefix(), ipe::Document::SProperties::iNumberPages, ipe::Symbol::iObject, ipe::Document::SProperties::iTexEngine, ipe::Platform::latexDirectory(), page(), properties(), ipe::Platform::readFile(), ipe::Platform::runLatex(), ipe::String::substr(), and ipe::String::z().

Referenced by runLatex().

## completeLatexRun()

int Document::completeLatexRun | ( | Latex * | converter | ) |

References ErrLatexOutput, ErrNone, setResources(), ipe::Latex::takeResources(), and ipe::Latex::updateTextObjects().

Referenced by runLatex().

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

- ipedoc.h
- ipedoc.cpp