本文整理汇总了C++中SPDocument类的典型用法代码示例。如果您正苦于以下问题:C++ SPDocument类的具体用法?C++ SPDocument怎么用?C++ SPDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
ExecutionEnv::reselect (void) {
if (_doc == NULL) {
return;
}
SPDocument * doc = _doc->doc();
if (doc == NULL) {
return;
}
SPDesktop *desktop = (SPDesktop *)_doc;
sp_namedview_document_from_window(desktop);
if (desktop == NULL) {
return;
}
Inkscape::Selection * selection = desktop->getSelection();
for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); ++i) {
SPObject * obj = doc->getObjectById(i->c_str());
if (obj != NULL) {
selection->add(obj);
}
}
return;
}
示例2: showSvgDocument
bool ImageIcon::showSvgDocument(const SPDocument *docArg)
{
if (document)
document->doUnref();
SPDocument *doc = const_cast<SPDocument *>(docArg);
doc->doRef();
document = doc;
//This should remove it from the box, and free resources
//if (viewerGtkmm)
// viewerGtkmm->destroy();
GtkWidget *viewerGtk = sp_svg_view_widget_new(doc);
viewerGtkmm = Glib::wrap(viewerGtk);
viewerGtkmm->show();
pack_start(*viewerGtkmm, TRUE, TRUE, 0);
//GtkWidget *vbox = GTK_WIDGET(gobj());
//gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);
return true;
}
示例3: mesh_toolbox_watch_ec
static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
static sigc::connection c_selection_changed;
static sigc::connection c_selection_modified;
static sigc::connection c_subselection_changed;
static sigc::connection c_defs_release;
static sigc::connection c_defs_modified;
if (SP_IS_MESH_CONTEXT(ec)) {
// connect to selection modified and changed signals
Inkscape::Selection *selection = desktop->getSelection();
SPDocument *document = desktop->getDocument();
c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder));
c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder));
c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder));
c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder));
c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder));
ms_tb_selection_changed(selection, holder);
} else {
if (c_selection_changed)
c_selection_changed.disconnect();
if (c_selection_modified)
c_selection_modified.disconnect();
if (c_subselection_changed)
c_subselection_changed.disconnect();
if (c_defs_release)
c_defs_release.disconnect();
if (c_defs_modified)
c_defs_modified.disconnect();
}
}
示例4: sp_box3d_finish
static void sp_box3d_finish(Box3DContext *bc)
{
bc->_message_context->clear();
bc->ctrl_dragged = false;
bc->extruded = false;
if ( bc->item != NULL ) {
SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
SPDocument *doc = sp_desktop_document(desktop);
if (!doc || !doc->getCurrentPersp3D())
return;
SPBox3D *box = SP_BOX3D(bc->item);
box->orig_corner0 = bc->drag_origin_proj;
box->orig_corner7 = bc->drag_ptC_proj;
box->updateRepr();
box3d_relabel_corners(box);
desktop->canvas->end_forced_full_redraws();
sp_desktop_selection(desktop)->set(bc->item);
sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
_("Create 3D box"));
bc->item = NULL;
}
}
示例5: called
/**
\brief This actually draws the grid.
\param module The effect that was called (unused)
\param document What should be edited.
*/
void
Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
{
Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100));
if (selection->isEmpty()) {
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
gdouble doc_height = (document->doc())->getHeight();
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
bounding_area = temprec;
}
float spacings[2] = { module->get_param_float("xspacing"),
module->get_param_float("yspacing") };
float line_width = module->get_param_float("lineWidth");
float offsets[2] = { module->get_param_float("xoffset"),
module->get_param_float("yoffset") };
Glib::ustring path_data("");
path_data = build_lines(bounding_area,
offsets, spacings);
Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
//XML Tree being used directly here while it shouldn't be.
Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
path->setAttribute("d", path_data.c_str());
Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000");
style += ";stroke-width:";
gchar floatstring[64];
std::ostringstream stringstream;
stringstream << line_width;
sprintf(floatstring, "%s", stringstream.str().c_str());
style += floatstring;
style += "pt";
path->setAttribute("style", style.c_str());
current_layer->appendChild(path);
Inkscape::GC::release(path);
return;
}
示例6: sp_document_idle_handler
/**
* An idle handler to update the document. Returns true if
* the document needs further updates.
*/
static gint
sp_document_idle_handler(gpointer data)
{
SPDocument *doc = static_cast<SPDocument *>(data);
if (doc->_updateDocument()) {
doc->modified_id = 0;
return false;
} else {
return true;
}
}
示例7:
Inkscape::XML::Node *box3d_side_convert_to_path(Box3DSide *side) {
// TODO: Copy over all important attributes (see sp_selected_item_to_curved_repr() for an example)
SPDocument *doc = side->document;
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("d", side->getAttribute("d"));
repr->setAttribute("style", side->getAttribute("style"));
return repr;
}
示例8: open
/**
* \return A new document created from the filename passed in
* \brief This is a generic function to use the open function of
* a module (including Autodetect)
* \param key Identifier of which module to use
* \param filename The file that should be opened
*
* First things first, are we looking at an autodetection? Well if that's the case then the module
* needs to be found, and that is done with a database lookup through the module DB. The foreach
* function is called, with the parameter being a gpointer array. It contains both the filename
* (to find its extension) and where to write the module when it is found.
*
* If there is no autodetection, then the module database is queried with the key given.
*
* If everything is cool at this point, the module is loaded, and there is possibility for
* preferences. If there is a function, then it is executed to get the dialog to be displayed.
* After it is finished the function continues.
*
* Lastly, the open function is called in the module itself.
*/
SPDocument *
open(Extension *key, gchar const *filename)
{
Input *imod = NULL;
if (key == NULL) {
gpointer parray[2];
parray[0] = (gpointer)filename;
parray[1] = (gpointer)&imod;
db.foreach(open_internal, (gpointer)&parray);
} else {
imod = dynamic_cast<Input *>(key);
}
bool last_chance_svg = false;
if (key == NULL && imod == NULL) {
last_chance_svg = true;
imod = dynamic_cast<Input *>(db.get(SP_MODULE_KEY_INPUT_SVG));
}
if (imod == NULL) {
throw Input::no_extension_found();
}
imod->set_state(Extension::STATE_LOADED);
if (!imod->loaded()) {
throw Input::open_failed();
}
if (!imod->prefs(filename))
return NULL;
SPDocument *doc = imod->open(filename);
if (!doc) {
return NULL;
}
if (last_chance_svg) {
/* We can't call sp_ui_error_dialog because we may be
running from the console, in which case calling sp_ui
routines will cause a segfault. See bug 1000350 - bryce */
// sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
g_warning(_("Format autodetect failed. The file is being opened as SVG."));
}
/* This kinda overkill as most of these are already set, but I want
to make sure for this release -- TJG */
doc->setModifiedSinceSave(false);
sp_document_set_uri(doc, filename);
return doc;
}
示例9: evaluateSystemLanguage
static bool evaluateSystemLanguage(SPItem const *item, gchar const *value) {
if ( NULL == value )
return true;
std::set<Glib::ustring> language_codes;
gchar *str = NULL;
gchar **strlist = g_strsplit( value, ",", 0);
for ( int i = 0 ; (str = strlist[i]) ; i++ ) {
gchar *lngcode = preprocessLanguageCode(str);
if ( 0 == *lngcode )
continue;
language_codes.insert(lngcode);
gchar *pos = strchr (lngcode, '-');
if (pos)
{
// if subtag is used, primary tag is still a perfect match
*pos = 0;
if ( language_codes.find(lngcode) == language_codes.end() ) {
language_codes.insert(lngcode);
}
}
}
g_strfreev(strlist);
if (language_codes.empty())
return false;
SPDocument *document = SP_OBJECT_DOCUMENT(item);
Glib::ustring document_language = document->getLanguage();
if (document_language.size() == 0)
return false;
bool match = true;
strlist = g_strsplit( document_language.c_str(), ",", 0);
for ( int i = 0 ; (str = strlist[i]) ; i++ ) {
gchar *lngcode = preprocessLanguageCode(str);
if ( 0 == *lngcode )
continue;
if ( language_codes.find(lngcode) != language_codes.end() ) {
match = true;
break;
}
match = false;
}
g_strfreev(strlist);
return match;
}
示例10: showSvgFile
bool ImageIcon::showSvgFile(const Glib::ustring &theFileName)
{
Glib::ustring fileName = theFileName;
fileName = Glib::filename_to_utf8(fileName);
SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), 0);
if (!doc) {
g_warning("SVGView: error loading document '%s'\n", fileName.c_str());
return false;
}
showSvgDocument(doc);
doc->doUnref();
return true;
}
示例11: showSvgFromMemory
bool ImageIcon::showSvgFromMemory(const char *xmlBuffer)
{
if (!xmlBuffer)
return false;
gint len = (gint)strlen(xmlBuffer);
SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0);
if (!doc) {
g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer);
return false;
}
showSvgDocument(doc);
doc->doUnref();
return true;
}
示例12: sp_gradient_selector_add_vector_clicked
static void
sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *sel)
{
SPDocument *doc = sp_gradient_vector_selector_get_document (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors));
if (!doc)
return;
SPGradient *gr = sp_gradient_vector_selector_get_gradient( SP_GRADIENT_VECTOR_SELECTOR (sel->vectors));
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *repr = NULL;
if (gr) {
repr = gr->getRepr()->duplicate(xml_doc);
} else {
repr = xml_doc->createElement("svg:linearGradient");
Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop");
stop->setAttribute("offset", "0");
stop->setAttribute("style", "stop-color:#000;stop-opacity:1;");
repr->appendChild(stop);
Inkscape::GC::release(stop);
stop = xml_doc->createElement("svg:stop");
stop->setAttribute("offset", "1");
stop->setAttribute("style", "stop-color:#fff;stop-opacity:1;");
repr->appendChild(stop);
Inkscape::GC::release(stop);
}
doc->getDefs()->getRepr()->addChild(repr, NULL);
Glib::ustring old_id = gr->getId();
gr = SP_GRADIENT(doc->getObjectByRepr(repr));
// Rename the new gradients id to be similar to the cloned gradients
rename_id(gr, old_id);
sp_gradient_vector_selector_set_gradient( SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, gr);
sel->selectGradientInTree(gr);
Inkscape::GC::release(repr);
}
示例13: gradient_toolbox_check_ec
/**
* Checks the current tool and connects gradient aux toolbox signals if it happens to be the gradient tool.
* Called every time the current tool changes by signal emission.
*/
static void gradient_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
static sigc::connection connChanged;
static sigc::connection connModified;
static sigc::connection connSubselectionChanged;
static sigc::connection connDefsRelease;
static sigc::connection connDefsModified;
if (SP_IS_GRADIENT_CONTEXT(ec)) {
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPDocument *document = sp_desktop_document(desktop);
// connect to selection modified and changed signals
connChanged = selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), holder));
connModified = selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), holder));
connSubselectionChanged = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), holder));
// Is this necessary? Couldn't hurt.
gr_tb_selection_changed(selection, holder);
// connect to release and modified signals of the defs (i.e. when someone changes gradient)
connDefsRelease = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder)));
connDefsModified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder)));
} else {
if (connChanged)
connChanged.disconnect();
if (connModified)
connModified.disconnect();
if (connSubselectionChanged)
connSubselectionChanged.disconnect();
if (connDefsRelease)
connDefsRelease.disconnect();
if (connDefsModified)
connDefsModified.disconnect();
}
}
示例14: perform_document_update
static void perform_document_update(SPDocument &doc) {
sp_repr_begin_transaction(doc.rdoc);
doc.ensureUpToDate();
Inkscape::XML::Event *update_log=sp_repr_commit_undoable(doc.rdoc);
if (update_log != NULL) {
g_warning("Document was modified while being updated after undo operation");
sp_repr_debug_print_log(update_log);
//Coalesce the update changes with the last action performed by user
if (!doc.priv->undo.empty()) {
Inkscape::Event* undo_stack_top = doc.priv->undo.back();
undo_stack_top->event = sp_repr_coalesce_log(undo_stack_top->event, update_log);
} else {
sp_repr_free_log(update_log);
}
}
}
示例15: sp_desktop_document
SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, Geom::Point p1)
{
SPDocument *doc = sp_desktop_document (desktop);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *root_repr = xml_doc->createElement("svg:flowRoot");
root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
SPItem *ft_item = SP_ITEM(desktop->currentLayer()->appendChildRepr(root_repr));
SPObject *root_object = doc->getObjectByRepr(root_repr);
g_assert(SP_IS_FLOWTEXT(root_object));
Inkscape::XML::Node *region_repr = xml_doc->createElement("svg:flowRegion");
root_repr->appendChild(region_repr);
SPObject *region_object = doc->getObjectByRepr(region_repr);
g_assert(SP_IS_FLOWREGION(region_object));
Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); // FIXME: use path!!! after rects are converted to use path
region_repr->appendChild(rect_repr);
SPRect *rect = SP_RECT(doc->getObjectByRepr(rect_repr));
p0 *= desktop->dt2doc();
p1 *= desktop->dt2doc();
using Geom::X;
using Geom::Y;
Geom::Coord const x0 = MIN(p0[X], p1[X]);
Geom::Coord const y0 = MIN(p0[Y], p1[Y]);
Geom::Coord const x1 = MAX(p0[X], p1[X]);
Geom::Coord const y1 = MAX(p0[Y], p1[Y]);
Geom::Coord const w = x1 - x0;
Geom::Coord const h = y1 - y0;
rect->setPosition(x0, y0, w, h);
rect->updateRepr();
Inkscape::XML::Node *para_repr = xml_doc->createElement("svg:flowPara");
root_repr->appendChild(para_repr);
SPObject *para_object = doc->getObjectByRepr(para_repr);
g_assert(SP_IS_FLOWPARA(para_object));
Inkscape::XML::Node *text = xml_doc->createTextNode("");
para_repr->appendChild(text);
Inkscape::GC::release(root_repr);
Inkscape::GC::release(region_repr);
Inkscape::GC::release(para_repr);
Inkscape::GC::release(rect_repr);
ft_item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
return ft_item;
}