本文整理汇总了C++中SPDocument::getDefaultUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ SPDocument::getDefaultUnit方法的具体用法?C++ SPDocument::getDefaultUnit怎么用?C++ SPDocument::getDefaultUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPDocument
的用法示例。
在下文中一共展示了SPDocument::getDefaultUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: input
SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
{
RVNGFileStream input(uri);
if (!libvisio::VisioDocument::isSupported(&input)) {
return NULL;
}
RVNGStringVector output;
#if WITH_LIBVISIO01
librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
if (!libvisio::VisioDocument::parse(&input, &generator)) {
#else
if (!libvisio::VisioDocument::generateSVG(&input, output)) {
#endif
return NULL;
}
if (output.empty()) {
return NULL;
}
std::vector<RVNGString> tmpSVGOutput;
for (unsigned i=0; i<output.size(); ++i) {
RVNGString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
tmpString.append(output[i]);
tmpSVGOutput.push_back(tmpString);
}
unsigned page_num = 1;
// If only one page is present, import that one without bothering user
if (tmpSVGOutput.size() > 1) {
VsdImportDialog *dlg = 0;
if (inkscape_use_gui()) {
dlg = new VsdImportDialog(tmpSVGOutput);
if (!dlg->showDialog()) {
delete dlg;
return NULL;
}
}
// Get needed page
if (dlg) {
page_num = dlg->getSelectedPage();
if (page_num < 1)
page_num = 1;
if (page_num > tmpSVGOutput.size())
page_num = tmpSVGOutput.size();
}
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
}
#include "clear-n_.h"
void VsdInput::init(void)
{
/* VSD */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("VSD Input") "</name>\n"
"<id>org.inkscape.input.vsd</id>\n"
"<input>\n"
"<extension>.vsd</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
"<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
/* VDX */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("VDX Input") "</name>\n"
"<id>org.inkscape.input.vdx</id>\n"
"<input>\n"
"<extension>.vdx</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"<filetypename>" N_("Microsoft Visio XML Diagram (*.vdx)") "</filetypename>\n"
"<filetypetooltip>" N_("File format used by Microsoft Visio 2010 and later") "</filetypetooltip>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
/* VSDM */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("VSDM Input") "</name>\n"
"<id>org.inkscape.input.vsdm</id>\n"
"<input>\n"
"<extension>.vsdm</extension>\n"
//.........这里部分代码省略.........
示例2: pb
//.........这里部分代码省略.........
link = mod_link;
}
prefs->setString("/dialogs/import/link", link );
if( forcexdpi != mod_forcexdpi ) {
forcexdpi = mod_forcexdpi;
}
prefs->setBool("/dialogs/import/forcexdpi", forcexdpi );
if( scale.compare( mod_scale ) != 0 ) {
scale = mod_scale;
}
prefs->setString("/dialogs/import/scale", scale );
prefs->setBool("/dialogs/import/ask", !mod->get_param_bool("do_not_ask") );
}
bool embed = ( link.compare( "embed" ) == 0 );
SPDocument *doc = NULL;
boost::scoped_ptr<Inkscape::Pixbuf> pb(Inkscape::Pixbuf::create_from_file(uri));
// TODO: the pixbuf is created again from the base64-encoded attribute in SPImage.
// Find a way to create the pixbuf only once.
if (pb) {
doc = SPDocument::createNewDoc(NULL, TRUE, TRUE);
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false); // no need to undo in this temporary document
double width = pb->width();
double height = pb->height();
double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px"));
//bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
ImageResolution *ir = 0;
double xscale = 1;
double yscale = 1;
if (!ir && !forcexdpi) {
ir = new ImageResolution(uri);
}
if (ir && ir->ok()) {
xscale = 900.0 / floor(10.*ir->x() + .5); // round-off to 0.1 dpi
yscale = 900.0 / floor(10.*ir->y() + .5);
} else {
xscale = 90.0 / defaultxdpi;
yscale = 90.0 / defaultxdpi;
}
width *= xscale;
height *= yscale;
delete ir; // deleting NULL is safe
// Create image node
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image");
sp_repr_set_svg_double(image_node, "width", width);
sp_repr_set_svg_double(image_node, "height", height);
// Added 11 Feb 2014 as we now honor "preserveAspectRatio" and this is
// what Inkscaper's expect.
image_node->setAttribute("preserveAspectRatio", "none");
if( scale.compare( "auto" ) != 0 ) {
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "image-rendering", scale.c_str());
sp_repr_css_set(image_node, css, "style");
sp_repr_css_attr_unref( css );
}
if (embed) {
sp_embed_image(image_node, pb.get());
} else {
// convert filename to uri
gchar* _uri = g_filename_to_uri(uri, NULL, NULL);
if(_uri) {
image_node->setAttribute("xlink:href", _uri);
g_free(_uri);
} else {
image_node->setAttribute("xlink:href", uri);
}
}
// Add it to the current layer
doc->getRoot()->appendChildRepr(image_node);
Inkscape::GC::release(image_node);
fit_canvas_to_drawing(doc);
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
//std::cout << "Viewbox not set, setting" << std::endl;
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
// restore undo, as now this document may be shown to the user if a bitmap was opened
DocumentUndo::setUndoSensitive(doc, saved);
} else {
printf("GdkPixbuf loader failed\n");
}
return doc;
}
示例3: input
SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
{
RVNGFileStream input(uri);
if (!libcdr::CDRDocument::isSupported(&input)) {
return NULL;
}
RVNGStringVector output;
#if WITH_LIBCDR01
librevenge::RVNGSVGDrawingGenerator generator(output, "svg");
if (!libcdr::CDRDocument::parse(&input, &generator)) {
#else
if (!libcdr::CDRDocument::generateSVG(&input, output)) {
#endif
return NULL;
}
if (output.empty()) {
return NULL;
}
std::vector<RVNGString> tmpSVGOutput;
for (unsigned i=0; i<output.size(); ++i) {
RVNGString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
tmpString.append(output[i]);
tmpSVGOutput.push_back(tmpString);
}
unsigned page_num = 1;
// If only one page is present, import that one without bothering user
if (tmpSVGOutput.size() > 1) {
CdrImportDialog *dlg = 0;
if (inkscape_use_gui()) {
dlg = new CdrImportDialog(tmpSVGOutput);
if (!dlg->showDialog()) {
delete dlg;
return NULL;
}
}
// Get needed page
if (dlg) {
page_num = dlg->getSelectedPage();
if (page_num < 1)
page_num = 1;
if (page_num > tmpSVGOutput.size())
page_num = tmpSVGOutput.size();
}
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (doc && !doc->getRoot()->viewBox_set) {
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
}
#include "clear-n_.h"
void CdrInput::init(void)
{
/* CDR */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Corel DRAW Input") "</name>\n"
"<id>org.inkscape.input.cdr</id>\n"
"<input>\n"
"<extension>.cdr</extension>\n"
"<mimetype>image/x-xcdr</mimetype>\n"
"<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n"
"<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
/* CDT */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Corel DRAW templates input") "</name>\n"
"<id>org.inkscape.input.cdt</id>\n"
"<input>\n"
"<extension>.cdt</extension>\n"
"<mimetype>application/x-xcdt</mimetype>\n"
"<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n"
"<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
/* CCX */
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n"
"<id>org.inkscape.input.ccx</id>\n"
"<input>\n"
"<extension>.ccx</extension>\n"
"<mimetype>application/x-xccx</mimetype>\n"
//.........这里部分代码省略.........