clipboard.cpp revision 8407bdf594617aded69904582aabe7ba2e055dd2
252N/A * Incorporates some code from selection-chemistry.cpp, see that file for more credits.
252N/A#include "ui/clipboard.h"
252N/A#include "inkscape.h"
252N/A#include "io/stringstream.h"
252N/A#include "desktop-handles.h"
252N/A#include "document.h"
252N/A#include "document-private.h"
252N/A#include "selection.h"
252N/A#include "message-stack.h"
252N/A#include "context-fns.h"
252N/A#include "selection-chemistry.h"
252N/A#include "libnr/nr-convert2geom.h"
#include "box3d.h"
#include "gradient-drag.h"
#include "sp-item.h"
#include "sp-path.h"
#include "sp-pattern.h"
#include "sp-shape.h"
#include "sp-gradient.h"
#include "sp-gradient-reference.h"
#include "sp-gradient-fns.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-textpath.h"
#include "sp-rect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
#include "text-context.h"
#include "text-editing.h"
#include "tools-switch.h"
#include "path-chemistry.h"
#include "id-clash.h"
#include "unit-constants.h"
#include "helper/png-write.h"
#include "svg/svg-color.h"
#include "sp-namedview.h"
#include "snap.h"
#ifdef WIN32
#include <windows.h>
// Clipboard Formats: http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx
namespace Inkscape {
namespace UI {
Inkscape::XML::Node *_copyNode(Inkscape::XML::Node *, Inkscape::XML::Document *, Inkscape::XML::Node *);
void _onClear();
void _createInternalClipboard();
void _discardInternalClipboard();
Geom::Scale _getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y);
void _setClipboardTargets();
#ifdef WIN32
if (_text_style) {
if (_text_style) {
// TODO: Handle x-special/gnome-copied-files and text/uri-list to support pasting files
return NULL;
if (!root) {
return NULL;
if (ch) {
return NULL;
if (_text_style) {
bool pasted = false;
if (clipnode) {
pasted = true;
return pasted;
bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y)
bool pasted = false;
if (clipnode) {
if (separately) {
if ( !obj_size ) {
if ( sel_size ) {
pasted = true;
return pasted;
if ( tempdoc ) {
if ( clipnode ) {
if ( effectstack ) {
for (GSList *itemptr = const_cast<GSList *>(selection->itemList()) ; itemptr ; itemptr = itemptr->next) {
return svgd;
* @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found
return svgd;
if (sorted_items) {
if (effect) {
if (size) {
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
if (lpeobj) {
if (SP_IS_ITEM(o)) {
if (SP_IS_ITEM(o)) {
while (gradient) {
while (pattern) {
for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
if (!path) {
Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, Inkscape::XML::Document *target_doc, Inkscape::XML::Node *parent)
return dup;
sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false);
if (sel_bbox) {
if (clipnode) {
if (!in_place) {
m.unSetup();
if (!img) {
// TODO unify with interface.cpp's sp_ui_drag_data_received()
if (css) {
bool attempt_alpha = false;
return NULL;
attempt_alpha = true;
return NULL;
attempt_alpha = true;
++str;
return color_css;
return NULL;
if (!obj) {
return NULL;
bool file_saved = false;
#ifdef WIN32
if (hglb) {
if (hemf) {
file_saved = true;
if (!file_saved) {
return NULL;
// from documentation: "Returns: A SelectionData object, which will be invalid if retrieving the given target failed."
// I don't know how to check whether an object is 'valid' or not, unusable if that's not possible...
target = sel.get_target(); // this can crash if the result was invalid of last function. No way to check for this :(
return tempdoc;
Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed);
sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, NULL);
if (_text_style) {
Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y)
if (apply_x) {
if (apply_y) {
#ifdef WIN32
while (format) {
return CLIPBOARD_WIN32_EMF_TARGET;
return CLIPBOARD_GDK_PIXBUF_TARGET;
return CLIPBOARD_WIN32_EMF_TARGET;
return CLIPBOARD_GDK_PIXBUF_TARGET;
return CLIPBOARD_TEXT_TARGET;
bool plaintextSet = false;
for (Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin() ; out != outlist.end() ; ++out) {
plaintextSet = true;
#ifdef WIN32
if (hemf) {
// of this method, as copied from /gtkmm-2.16.0/gtk/gtkmm/clipboard.cc.
gboolean test = gtk_clipboard_wait_for_targets( gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), &targets, &n_targets );
if (!test) {
for (int i = 0; i < n_targets; i++)
if (atom_name) {
return _instance;