+ if (p == PSPPIRE_DATA_EDITOR_DATA_VIEW)
+ {
+ PsppireDict *dict = NULL;
+ g_object_get (dw->data_editor, "dictionary", &dict, NULL);
+
+ gint x, y;
+ SswSheet *sheet = SSW_SHEET (dw->data_editor->data_sheet);
+ SswRange sel = *sheet->selection;
+
+ if (ssw_sheet_try_cut (sheet))
+ return;
+
+ if (sel.start_x > sel.end_x)
+ {
+ gint tmp = sel.start_x;
+ sel.start_x = sel.end_x;
+ sel.end_x = tmp;
+ }
+ if (sel.start_y > sel.end_y)
+ {
+ gint tmp = sel.start_y;
+ sel.start_y = sel.end_y;
+ sel.end_y = tmp;
+ }
+
+ GtkClipboard *clip =
+ gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
+ GDK_SELECTION_CLIPBOARD);
+
+ /* Save the selected area to a string */
+ GString *str = g_string_new ("");
+ for (y = sel.start_y ; y <= sel.end_y; ++y)
+ {
+ for (x = sel.start_x ; x <= sel.end_x; ++x)
+ {
+ const struct variable * var = psppire_dict_get_variable (dict, x);
+ gboolean use_value_label = FALSE;
+ g_object_get (dw->data_editor, "value-labels", &use_value_label, NULL);
+ gchar *s = psppire_data_store_get_string (dw->data_editor->data_store,
+ y, var, use_value_label);
+ g_string_append (str, s);
+ if (x < sel.end_x)
+ g_string_append (str, "\t");
+ g_free (s);
+ }
+ if (y < sel.end_y)
+ g_string_append (str, "\n");
+ }
+
+ gtk_clipboard_set_text (clip, str->str, str->len);
+ g_string_free (str, TRUE);
+
+ /* Now fill the selected area with SYSMIS or blanks */
+ for (x = sel.start_x ; x <= sel.end_x; ++x)
+ {
+ const struct variable *var = psppire_dict_get_variable (dict, x);
+ int width = var_get_width (var);
+ union value sm ;
+ value_init (&sm, width);
+ if (var_is_numeric (var))
+ sm.f = SYSMIS;
+ else
+ memset (sm.s, 0, width);
+ for (y = sel.start_y ; y <= sel.end_y; ++y)
+ {
+ psppire_data_store_set_value (dw->data_editor->data_store,
+ y,
+ var, &sm);
+ }
+ value_destroy (&sm, width);
+ }