Ipelib
|
#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, ErrNoIconv } |
Public Member Functions | |
Document () | |
Document (const Document &rhs) | |
~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 | setFontPool (FontPool *fontPool) |
const FontPool * | fontPool () const |
bool | hasTrueTypeFonts () const |
bool | hasTransparency () const |
bool | hasTilings () const |
bool | hasGradients () const |
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) |
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.
anonymous enum |
anonymous enum |
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::Document | ( | const Document & | rhs | ) |
Copy constructor.
References countPages(), and page().
Document::~Document | ( | ) |
Destructor.
References countPages(), and page().
|
static |
|
static |
Determine format of file from filename fn.
References EEps, EPdf, EUnknown, EXml, ipe::String::right(), and ipe::String::size().
|
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().
|
static |
References EFileOpenError, fileFormat(), ipe::Platform::fopen(), and load().
|
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::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::iTitle, ipe::Bitmap::objNum(), page(), ipe::Stream::putXmlString(), ipe::Page::saveAsXml(), ipe::Bitmap::saveAsXml(), and ipe::Cascade::saveAsXml().
Referenced by save().
|
inline |
Return number of pages of document.
Referenced by checkStyle(), countTotalViews(), ipe::PdfWriter::createTrailer(), Document(), findBitmaps(), ipe::PageSelector::PageSelector(), runLatex(), saveAsXml(), ipe::CanvasBase::selectPageOrView(), and ~Document().
int Document::countTotalViews | ( | ) | const |
Return total number of views in all pages.
References countPages(), ipe::Page::countViews(), and page().
Referenced by ipe::PdfWriter::createTrailer().
|
inline |
Return page (const version).
The first page is no 0.
Referenced by checkStyle(), countTotalViews(), ipe::PdfWriter::createBookmarks(), ipe::PdfWriter::createPages(), ipe::PdfWriter::createPageView(), ipe::PdfWriter::createTrailer(), Document(), findBitmaps(), insert(), ipe::PageSelector::PageSelector(), runLatex(), saveAsXml(), ipe::CanvasBase::selectPageOrView(), set(), and ~Document().
|
inline |
Return page.
The first page is no 0.
void Document::insert | ( | int | no, |
Page * | page | ||
) |
void Document::push_back | ( | Page * | page | ) |
Append a new page.
Referenced by ipe::ImlParser::parseDocument().
Page * Document::remove | ( | int | no | ) |
Remove a page.
Returns the page that has been removed.
|
inline |
Return document properties.
Referenced by ipe::PdfWriter::createTrailer(), ipe::ImlParser::parseDocument(), and runLatex().
void Document::setProperties | ( | const SProperties & | info | ) |
Set document properties.
Referenced by ipe::ImlParser::parseDocument().
|
inline |
Return stylesheet cascade.
Referenced by checkStyle(), ipe::PdfWriter::createPageView(), ipe::ImlParser::parseDocument(), ipe::Thumbnail::render(), runLatex(), ipe::Thumbnail::saveRender(), and ipe::Thumbnail::Thumbnail().
|
inline |
Return stylesheet cascade (const version).
Replace the entire style sheet cascade.
Takes ownership of cascade, and returns the original cascade.
void Document::setFontPool | ( | FontPool * | fontPool | ) |
Update the font pool (after running Pdflatex).
Takes ownership of the font pool.
References fontPool().
Referenced by runLatex().
|
inline |
Return the current FontPool.
Referenced by setFontPool(), and ipe::Thumbnail::Thumbnail().
bool Document::hasTrueTypeFonts | ( | ) | const |
Return whether this document uses any Truetype fonts.
References ipe::Font::ETrueType.
bool Document::hasTransparency | ( | ) | const |
Does this document make any use of transparency?
The document is considered to make use of transparency if its style sheets define any opacities whose value is not 1.0.
References ipe::Cascade::allNames(), ipe::EOpacity, ipe::Cascade::find(), and ipe::Attribute::ONE().
bool Document::hasTilings | ( | ) | const |
Does this document contain any tiling patterns?
References ipe::Cascade::allNames(), and ipe::ETiling.
bool Document::hasGradients | ( | ) | const |
Does this document contain any gradients?
References ipe::Cascade::allNames(), and ipe::EGradient.
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 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().
int Document::runLatex | ( | String & | logFile | ) |
Run PdfLatex.
References ipe::Cascade::allNames(), cascade(), countPages(), ipe::Latex::createLatexSource(), ipe::String::data(), ipe::String::empty(), ErrLatex, ErrLatexOutput, ErrNoDir, ErrNoIconv, ErrNone, ErrNoText, ErrRunLatex, ErrWritingSource, ipe::ESymbol, ipe::String::find(), ipe::Cascade::findEncoding(), ipe::Cascade::findSymbol(), ipe::Platform::fopen(), ipe::Symbol::iObject, ipe::Platform::latexDirectory(), ipe::String::left(), page(), properties(), ipe::FileStream::putRaw(), ipe::Platform::readFile(), ipe::Latex::readPdf(), ipe::Platform::runPdfLatex(), ipe::Latex::scanObject(), ipe::Latex::scanPage(), setFontPool(), ipe::String::size(), ipe::String::substr(), ipe::Latex::takeFontPool(), 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, ErrNoIconv, ErrNone, ErrNoText, ErrOldPdfLatex, ErrRunLatex, and ErrWritingSource.