Ipelib
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ipe::Document Class Reference

#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)
 
Documentoperator= (const Document &rhs)=delete
 
 ~Document ()
 
bool save (TellStream &stream, TFormat format, uint32_t flags) const
 
bool save (const char *fname, TFormat format, uint32_t flags) const
 
bool exportPages (const char *fname, uint32_t flags, int fromPage, int toPage) const
 
bool exportView (const char *fname, TFormat format, uint32_t flags, int pno, int vno) const
 
void saveAsXml (Stream &stream, bool usePdfBitmaps=false) const
 
int countPages () const
 
int countTotalViews () const
 
const Pagepage (int no) const
 
Pagepage (int no)
 
int findPage (String nameOrNumber) const
 
Pageset (int no, Page *page)
 
void insert (int no, Page *page)
 
void push_back (Page *page)
 
Pageremove (int no)
 
SProperties properties () const
 
void setProperties (const SProperties &info)
 
Cascadecascade ()
 
const Cascadecascade () const
 
CascadereplaceCascade (Cascade *cascade)
 
void setResources (PdfResources *resources)
 
const PdfResourcesresources () 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 Documentload (DataSource &source, TFormat format, int &reason)
 
static Documentload (const char *fname, int &reason)
 
static DocumentloadWithErrorReport (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

◆ 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

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.

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

Referenced by formatFromFilename().

◆ Document() [2/2]

Document::Document ( const Document rhs)

Copy constructor.

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

◆ ~Document()

Document::~Document ( )

Destructor.

References countPages(), and page().

Member Function Documentation

◆ operator=()

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

◆ fileFormat()

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

◆ formatFromFilename()

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

◆ load() [1/2]

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

◆ load() [2/2]

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

◆ loadWithErrorReport()

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

◆ save() [1/2]

bool ipe::Document::save ( TellStream stream,
TFormat  format,
uint32_t  flags 
) const

Referenced by loadWithErrorReport().

◆ save() [2/2]

bool ipe::Document::save ( const char *  fname,
TFormat  format,
uint32_t  flags 
) const

◆ exportPages()

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

◆ exportView()

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

◆ saveAsXml()

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

◆ countPages()

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

◆ countTotalViews()

int Document::countTotalViews ( ) const

Return total number of views in all pages.

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

Referenced by countPages().

◆ page() [1/2]

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

◆ page() [2/2]

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

Return page.

The first page is no 0.

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

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

Referenced by page().

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

Referenced by page().

◆ push_back()

void Document::push_back ( Page page)

Append a new page.

Referenced by page(), and 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.

References setProperties().

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

◆ setProperties()

void Document::setProperties ( const SProperties info)

Set document properties.

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

◆ cascade() [1/2]

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

◆ cascade() [2/2]

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

Return stylesheet cascade (const version).

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

◆ replaceCascade()

Cascade * Document::replaceCascade ( Cascade sheets)

Replace the entire style sheet cascade.

Takes ownership of cascade, and returns the original cascade.

Referenced by cascade().

◆ setResources()

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

◆ resources()

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

Return the current PDF resources.

References checkStyle(), and findBitmaps().

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

◆ findBitmaps()

void Document::findBitmaps ( BitmapFinder bm) const

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

Referenced by resources().

◆ runLatex() [1/2]

int Document::runLatex ( String logFile)

◆ runLatex() [2/2]

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: