Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Inkscape::Extension::Output Class Reference

#include <output.h>

Inheritance diagram for Inkscape::Extension::Output:
Inkscape::Extension::Extension

Classes

class  export_id_not_found
 
class  file_read_only
 The existing file can not be opened for writing. More...
 
struct  lost_document
 Document was closed during execution of async extension. More...
 
class  no_extension_found
 Failed because we couldn't find an extension to match the filename. More...
 
class  save_cancelled
 Saving was cancelled. More...
 
class  save_failed
 Generic failure for an undescribed reason. More...
 

Public Member Functions

 Output (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
 Builds an Output object from a XML description.
 
 ~Output () override
 Destroy an output extension.
 
bool check () override
 Validate this extension.
 
void save (SPDocument *doc, gchar const *filename, bool detachbase=false)
 Save a document as a file.
 
void export_raster (const SPDocument *doc, std::string png_filename, gchar const *filename, bool detachbase)
 Save a rendered png as a raster output.
 
gchar const * get_mimetype () const
 Get the mime-type that describes this extension.
 
gchar const * get_extension () const
 Get the filename extension for this extension.
 
const char * get_filetypename (bool translated=false) const
 Get the name of the filetype supported.
 
const char * get_filetypetooltip (bool translated=false) const
 Get the tooltip for more information on the filetype.
 
bool causes_dataloss () const
 
bool savecopy_only () const
 
bool is_raster () const
 
bool is_exported () const
 
void add_extension (std::string &filename)
 Adds a valid extension to the filename if it's missing.
 
bool can_save_filename (gchar const *filename) const
 Match filename to extension that can open it.
 
- Public Member Functions inherited from Inkscape::Extension::Extension
 Extension (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
 Constructs an Extension from a Inkscape::XML::Node.
 
virtual ~Extension ()
 
void set_state (state_t in_state)
 A function to set whether the extension should be loaded or unloaded.
 
state_t get_state ()
 A getter for the state variable.
 
bool loaded ()
 A quick function to test the state of the extension.
 
virtual bool prefs ()
 Create a dialog for preference for this extension.
 
Inkscape::XML::Nodeget_repr ()
 A getter for the internal Repr, does not add a reference.
 
char const * get_id () const
 Get the ID of this extension - not a copy don't delete!
 
char const * get_name () const
 Get the name of this extension - not a copy don't delete!
 
virtual void deactivate ()
 This function diactivates the extension (which makes it unusable, but not deleted)
 
bool deactivated ()
 Find out the status of the extension.
 
void printFailure (Glib::ustring const &reason)
 A quick function to print out a standard start of extension errors in the log.
 
std::string const & getErrorReason ()
 
Implementation::Implementationget_imp ()
 
auto const & get_base_directory () const
 
void set_base_directory (std::string const &base_directory)
 
std::string get_dependency_location (char const *name)
 Gets the location of the dependency file as an absolute path.
 
char const * get_translation (char const *msgid, char const *msgctxt=nullptr) const
 Gets a translation within the context of the current extension.
 
void set_environment (SPDocument const *doc=nullptr)
 Sets environment suitable for executing this Extension.
 
ModuleImpType get_implementation_type ()
 Uses the object's type to figure out what the type is.
 
int get_sort_priority () const
 
void set_sort_priority (int priority)
 
virtual void run_processing_actions (SPDocument *doc)
 Runs any pre-processing actions and modifies the document.
 
unsigned int widget_visible_count () const
 A function to get the number of visible parameters of the extension.
 
bool get_param_bool (char const *name) const
 Gets a parameter identified by name with the bool placed in value.
 
bool get_param_bool (char const *name, bool alt) const
 Like get_param_bool but with a default on param_not_exist error.
 
int get_param_int (char const *name) const
 Gets a parameter identified by name with the integer placed in value.
 
int get_param_int (char const *name, int alt) const
 Like get_param_int but with a default on param_not_exist error.
 
double get_param_float (char const *name) const
 Gets a float parameter identified by name with the double placed in value.
 
double get_param_float (char const *name, double alt) const
 Like get_param_float but with a default on param_not_exist error.
 
char const * get_param_string (char const *name, char const *alt) const
 Like get_param_string but with a default on param_not_exist error.
 
char const * get_param_string (char const *name) const
 Gets a parameter identified by name with the string placed in value.
 
char const * get_param_optiongroup (char const *name, char const *alt) const
 Like get_param_optiongroup but with a default on param_not_exist error.
 
char const * get_param_optiongroup (char const *name) const
 Gets a parameter identified by name with the string placed in value.
 
Colors::Color get_param_color (char const *name) const
 Gets a parameter identified by name with the unsigned int placed in value.
 
bool get_param_optiongroup_contains (char const *name, char const *value) const
 This is useful to find out, if a given string value is selectable in a optiongroup named \cname.
 
bool set_param_bool (char const *name, bool value)
 Sets a parameter identified by name with the boolean in the parameter value.
 
int set_param_int (char const *name, int value)
 Sets a parameter identified by name with the integer in the parameter value.
 
double set_param_float (char const *name, double value)
 Sets a parameter identified by name with the double in the parameter value.
 
char const * set_param_string (char const *name, char const *value)
 Sets a parameter identified by name with the string in the parameter value.
 
char const * set_param_optiongroup (char const *name, char const *value)
 Sets a parameter identified by name with the string in the parameter value.
 
void set_param_color (char const *name, Colors::Color const &color)
 
void set_param_any (char const *name, std::string const &value)
 Parses the given string value and sets a parameter identified by name.
 
void set_param_hidden (char const *name, bool hidden)
 
Gtk::Widget * autogui (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal< void()> *changeSignal=nullptr)
 A function to automatically generate a GUI from the extensions' widgets.
 
void paramListString (std::list< std::string > &retlist) const
 A function to get the parameters in a string form.
 
void set_gui (bool s)
 
bool get_gui () const
 
Gtk::Box * get_info_widget ()
 
Gtk::Box * get_params_widget ()
 

Private Attributes

gchar * mimetype
 What is the mime type this inputs?
 
gchar * extension
 The extension of the input files.
 
gchar * filetypename
 A userfriendly name for the file type.
 
gchar * filetypetooltip
 A more detailed description of the filetype.
 
bool dataloss
 The extension causes data loss on save.
 
bool savecopyonly
 Limit output option to Save a Copy.
 
bool raster = false
 Is the extension expecting a png file.
 
bool exported = false
 Is the extension available in the export dialog.
 

Additional Inherited Members

- Public Types inherited from Inkscape::Extension::Extension
enum  state_t { STATE_LOADED , STATE_UNLOADED , STATE_DEACTIVATED }
 An enumeration to identify if the Extension has been loaded or not. More...
 
using ImplementationHolder = Util::HybridPointer< Implementation::Implementation >
 
- Static Public Member Functions inherited from Inkscape::Extension::Extension
static void error_file_open ()
 A function to open the error log file.
 
static void error_file_close ()
 A function to close the error log file.
 
static void error_file_write (Glib::ustring const &text)
 A function to write to the error log file.
 
- Static Protected Member Functions inherited from Inkscape::Extension::Extension
static void add_val (Glib::ustring const &labelstr, Glib::ustring const &valuestr, Gtk::Grid *table, int *row)
 
- Protected Attributes inherited from Inkscape::Extension::Extension
Inkscape::XML::Noderepr
 The XML description of the Extension.
 
ImplementationHolder imp
 An Implementation object provides the actual implementation of the Extension.
 
std::string _base_directory
 Directory containing the .inx file, relative paths in the extension should usually be relative to it.
 
std::unique_ptr< ExpirationTimertimer
 Timeout to unload after a given time.
 
bool _translation_enabled = true
 Attempt translation of strings provided by the extension?
 

Detailed Description

Definition at line 23 of file output.h.

Constructor & Destructor Documentation

◆ Output()

Inkscape::Extension::Output::Output ( Inkscape::XML::Node in_repr,
ImplementationHolder  implementation,
std::string *  base_directory 
)

Builds an Output object from a XML description.

Parameters
in_reprThe XML description in a Inkscape::XML::Node tree
implementationThe implementation of the extension

Okay, so you want to build an Output object.

This function looks for the <output> section of the XML description. Under there should be several fields which describe the output module to excruciating detail. Those are parsed, copied, and put into the structure that is passed in as module. Overall, there are many levels of indentation, just to handle the levels of indentation in the XML file.

Definition at line 41 of file output.cpp.

References Inkscape::XML::Node::attributeList(), Inkscape::XML::Node::content(), dataloss, exported, extension, filetypename, filetypetooltip, Inkscape::XML::Node::firstChild(), mimetype, name, Inkscape::XML::Node::name(), Inkscape::XML::Node::next(), raster, Inkscape::Extension::Extension::repr, savecopyonly, and Inkscape::Extension::Extension::set_sort_priority().

◆ ~Output()

Inkscape::Extension::Output::~Output ( )
override

Destroy an output extension.

Definition at line 116 of file output.cpp.

References extension, filetypename, filetypetooltip, and mimetype.

Member Function Documentation

◆ add_extension()

void Inkscape::Extension::Output::add_extension ( std::string &  filename)

Adds a valid extension to the filename if it's missing.

Only used by export-single.cpp.

Definition at line 252 of file output.cpp.

References extension, and Inkscape::IO::get_file_extension().

◆ can_save_filename()

bool Inkscape::Extension::Output::can_save_filename ( gchar const *  filename) const

Match filename to extension that can open it.

Returns
True if the filename matches

Definition at line 265 of file output.cpp.

References extension, and result.

◆ causes_dataloss()

bool Inkscape::Extension::Output::causes_dataloss ( ) const
inline

Definition at line 61 of file output.h.

References dataloss.

Referenced by Inkscape::Extension::save().

◆ check()

bool Inkscape::Extension::Output::check ( )
overridevirtual

Validate this extension.

Returns
Whether this extension checks out

This function checks to make sure that the output extension has a filename extension and a MIME type. Then it calls the parent class' check function which also checks out the implementation.

Reimplemented from Inkscape::Extension::Extension.

Definition at line 134 of file output.cpp.

References Inkscape::Extension::Extension::check(), extension, and mimetype.

◆ export_raster()

void Inkscape::Extension::Output::export_raster ( const SPDocument doc,
std::string  png_filename,
gchar const *  filename,
bool  detachbase 
)

Save a rendered png as a raster output.

Returns
None
Parameters
png_filenamesource png file.
filenameFile to save the raster as

Definition at line 237 of file output.cpp.

References Inkscape::Extension::Extension::imp, Inkscape::Extension::Extension::loaded(), Inkscape::Extension::Extension::set_state(), and Inkscape::Extension::Extension::STATE_LOADED.

Referenced by Inkscape::UI::Dialog::Export::exportRaster().

◆ get_extension()

gchar const * Inkscape::Extension::Output::get_extension ( ) const

Get the filename extension for this extension.

Returns
Filename extension for the extension

Definition at line 159 of file output.cpp.

References extension.

Referenced by Inkscape::UI::Dialog::FileSaveDialog::appendExtension(), and sp_file_save_dialog().

◆ get_filetypename()

const char * Inkscape::Extension::Output::get_filetypename ( bool  translated = false) const

Get the name of the filetype supported.

Returns
The name of the filetype supported

Definition at line 169 of file output.cpp.

References filetypename, Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Extension::get_translation(), and name.

◆ get_filetypetooltip()

const char * Inkscape::Extension::Output::get_filetypetooltip ( bool  translated = false) const

Get the tooltip for more information on the filetype.

Returns
Tooltip giving more information on the filetype

Definition at line 190 of file output.cpp.

References filetypetooltip, and Inkscape::Extension::Extension::get_translation().

◆ get_mimetype()

gchar const * Inkscape::Extension::Output::get_mimetype ( ) const

Get the mime-type that describes this extension.

Returns
IETF mime-type for the extension

Definition at line 149 of file output.cpp.

References mimetype.

Referenced by InkFileExportCmd::do_export_ps_pdf().

◆ is_exported()

bool Inkscape::Extension::Output::is_exported ( ) const
inline

Definition at line 64 of file output.h.

References exported.

◆ is_raster()

bool Inkscape::Extension::Output::is_raster ( ) const
inline

◆ save()

void Inkscape::Extension::Output::save ( SPDocument doc,
gchar const *  filename,
bool  detachbase = false 
)

Save a document as a file.

Returns
None
Parameters
docDocument to save
filenameFile to save the document as

This function does a little of the dirty work involved in saving a document so that the implementation only has to worry about getting bits on the disk.

The big thing that it does is remove and read the fields that are only used at runtime and shouldn't be saved. One that may surprise people is the output extension. This is not saved so that the IDs could be changed, and old files will still work properly.

Definition at line 215 of file output.cpp.

References SPDocument::copy(), Inkscape::Extension::Extension::imp, Inkscape::Extension::Extension::loaded(), Inkscape::Extension::Extension::run_processing_actions(), Inkscape::Extension::Extension::set_state(), and Inkscape::Extension::Extension::STATE_LOADED.

Referenced by InkFileExportCmd::do_export_extension(), Inkscape::UI::Dialog::Export::exportVector(), and Inkscape::Extension::save().

◆ savecopy_only()

bool Inkscape::Extension::Output::savecopy_only ( ) const
inline

Definition at line 62 of file output.h.

References savecopyonly.

Member Data Documentation

◆ dataloss

bool Inkscape::Extension::Output::dataloss
private

The extension causes data loss on save.

Definition at line 28 of file output.h.

Referenced by causes_dataloss(), and Output().

◆ exported

bool Inkscape::Extension::Output::exported = false
private

Is the extension available in the export dialog.

Definition at line 31 of file output.h.

Referenced by is_exported(), and Output().

◆ extension

gchar* Inkscape::Extension::Output::extension
private

The extension of the input files.

Definition at line 25 of file output.h.

Referenced by add_extension(), can_save_filename(), check(), get_extension(), Output(), and ~Output().

◆ filetypename

gchar* Inkscape::Extension::Output::filetypename
private

A userfriendly name for the file type.

Definition at line 26 of file output.h.

Referenced by get_filetypename(), Output(), and ~Output().

◆ filetypetooltip

gchar* Inkscape::Extension::Output::filetypetooltip
private

A more detailed description of the filetype.

Definition at line 27 of file output.h.

Referenced by get_filetypetooltip(), Output(), and ~Output().

◆ mimetype

gchar* Inkscape::Extension::Output::mimetype
private

What is the mime type this inputs?

Definition at line 24 of file output.h.

Referenced by check(), get_mimetype(), Output(), and ~Output().

◆ raster

bool Inkscape::Extension::Output::raster = false
private

Is the extension expecting a png file.

Definition at line 30 of file output.h.

Referenced by is_raster(), and Output().

◆ savecopyonly

bool Inkscape::Extension::Output::savecopyonly
private

Limit output option to Save a Copy.

Definition at line 29 of file output.h.

Referenced by Output(), and savecopy_only().


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