SswSheet *sheet = SSW_SHEET (dw->data_editor->data_sheet);
SswRange sel = *sheet->selection;
-#if (SSW_SHEET_API_VERSION >= 1)
- if ((ssw_sheet_get_api_version() >= 1) && ssw_sheet_try_cut (sheet))
+ if (ssw_sheet_try_cut (sheet))
return;
-#endif
+ 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);
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, FALSE);
+ y, var, use_value_label);
g_string_append (str, s);
- g_string_append (str, "\t");
+ if (x < sel.end_x)
+ g_string_append (str, "\t");
g_free (s);
}
- g_string_append (str, "\n");
+ 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 */
- union value sm ;
- sm.f = SYSMIS;
+ /* 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);
+ 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);
}
-
}
}