1 #ifndef _GNM_CLIPBOARD_H_ 2 # define _GNM_CLIPBOARD_H_ 3 4 #include <gnumeric.h> 5 #include <goffice/goffice.h> 6 7 G_BEGIN_DECLS 8 9 typedef enum { 10 PASTE_CONTENTS = 1 << 0, /* either CONTENTS or AS_VALUES */ 11 PASTE_AS_VALUES = 1 << 1, /* can be applied, not both */ 12 PASTE_FORMATS = 1 << 2, 13 PASTE_COMMENTS = 1 << 3, 14 PASTE_OBJECTS = 1 << 4, 15 16 /* Operations that can be performed at paste time on a cell */ 17 PASTE_OPER_ADD = 1 << 5, 18 PASTE_OPER_SUB = 1 << 6, 19 PASTE_OPER_MULT = 1 << 7, 20 PASTE_OPER_DIV = 1 << 8, 21 22 /* Whether the paste transposes or not */ 23 PASTE_TRANSPOSE = 1 << 9, 24 25 PASTE_LINK = 1 << 10, 26 27 /* If copying a range that includes blank cells, this 28 prevents pasting blank cells over existing data */ 29 PASTE_SKIP_BLANKS = 1 << 11, 30 31 /* Do not paste merged regions (probably not needed) */ 32 PASTE_DONT_MERGE = 1 << 12, 33 34 /* Internal flag : see cmd_merge_cells_undo for details */ 35 PASTE_IGNORE_COMMENTS_AT_ORIGIN = 1 << 13, 36 37 // Copy column widths 38 PASTE_COLUMN_WIDTHS = 1 << 14, 39 PASTE_COLUMN_WIDTHS_AUTO = 1 << 15, 40 PASTE_COLUMN_WIDTHS_MASK = (PASTE_COLUMN_WIDTHS | PASTE_COLUMN_WIDTHS_AUTO), 41 42 // Copy row heights 43 PASTE_ROW_HEIGHTS = 1 << 16, 44 PASTE_ROW_HEIGHTS_AUTO = 1 << 17, 45 PASTE_ROW_HEIGHTS_MASK = (PASTE_ROW_HEIGHTS | PASTE_ROW_HEIGHTS_AUTO), 46 47 PASTE_EXPR_LOCAL_RELOCATE = 1 << 18, 48 49 /* Avoid flagging dependencies. */ 50 PASTE_NO_RECALC = 1 << 19, 51 52 /* Whether the paste flips or not */ 53 PASTE_FLIP_H = 1 << 20, 54 PASTE_FLIP_V = 1 << 21, 55 56 PASTE_ALL_CELL = (PASTE_CONTENTS | PASTE_FORMATS | PASTE_COMMENTS | PASTE_OBJECTS), 57 PASTE_ALL_SHEET = (PASTE_ALL_CELL | PASTE_COLUMN_WIDTHS_AUTO | PASTE_ROW_HEIGHTS_AUTO), 58 PASTE_DEFAULT = PASTE_ALL_SHEET 59 } GnmPasteFlags; 60 61 #define PASTE_OPER_MASK (PASTE_OPER_ADD | PASTE_OPER_SUB | PASTE_OPER_MULT | PASTE_OPER_DIV) 62 63 typedef struct { 64 GnmCellPos const offset; /* must be first element */ 65 GnmValue *val; 66 GnmExprTop const *texpr; 67 } GnmCellCopy; 68 69 GType gnm_cell_copy_get_type (void); 70 71 struct _GnmCellRegion { 72 Sheet *origin_sheet; /* can be NULL */ 73 const GODateConventions *date_conv; /* can be NULL */ 74 GnmCellPos base; 75 int cols, rows; 76 ColRowStateList *col_state, *row_state; 77 GHashTable *cell_content; 78 GnmStyleList *styles; 79 GSList *merged; 80 GSList *objects; 81 gboolean not_as_contents; 82 83 unsigned ref_count; 84 }; 85 86 struct _GnmPasteTarget { 87 Sheet *sheet; 88 GnmRange range; 89 GnmPasteFlags paste_flags; 90 }; 91 92 GType gnm_paste_target_get_type (void); 93 94 GnmPasteTarget *gnm_paste_target_new (Sheet *sheet, GnmRange *r, GnmPasteFlags flags); 95 96 GnmCellRegion *clipboard_copy_range (Sheet *sheet, GnmRange const *r); 97 GOUndo *clipboard_copy_range_undo (Sheet *sheet, GnmRange const *r); 98 GOUndo *clipboard_copy_ranges_undo (Sheet *sheet, GSList *ranges); 99 GnmCellRegion *clipboard_copy_obj (Sheet *sheet, GSList *objects); 100 gboolean clipboard_paste_region (GnmCellRegion const *cr, 101 GnmPasteTarget const *pt, 102 GOCmdContext *cc); 103 GnmPasteTarget *paste_target_init (GnmPasteTarget *pt, 104 Sheet *sheet, GnmRange const *r, 105 GnmPasteFlags flags); 106 107 GType gnm_cell_region_get_type (void); 108 GnmCellRegion *gnm_cell_region_new (Sheet *origin_sheet); 109 GnmCellRegion *cellregion_ref (GnmCellRegion *cr); 110 void cellregion_unref (GnmCellRegion *cr); 111 GString *cellregion_to_string (GnmCellRegion const *cr, 112 gboolean only_visible, 113 GODateConventions const *date_conv); 114 int cellregion_cmd_size (GnmCellRegion const *cr); 115 void cellregion_invalidate_sheet (GnmCellRegion *cr, Sheet *sheet); 116 117 GnmCellCopy *gnm_cell_copy_new (GnmCellRegion *cr, 118 int col_offset, int row_offset); 119 120 void clipboard_init (void); 121 void clipboard_shutdown (void); 122 123 124 G_END_DECLS 125 126 #endif /* _GNM_CLIPBOARD_H_ */ 127