workbook-cmd-format.c 1.5 KB
Newer Older
1
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 3 4 5 6
/*
 * workbook.c:  Workbook format commands hooked to the menus
 *
 * Author:
 *   Miguel de Icaza (miguel@gnu.org)
Jody Goldberg's avatar
Jody Goldberg committed
7
 *   Jody Goldberg (jody@gnome.org)
8
 */
9
#include <gnumeric-config.h>
10
#include <glib/gi18n.h>
11
#include "gnumeric.h"
12 13
#include "workbook-cmd-format.h"

14
#include "dependent.h"
15
#include "ranges.h"
16
#include "gui-util.h"
17
#include "selection.h"
18
#include "workbook-control.h"
19
#include "workbook.h"
20
#include "application.h"
21
#include "dialogs.h"
22
#include "format.h"
Jody Goldberg's avatar
Jody Goldberg committed
23
#include "sheet.h"
24
#include "commands.h"
25 26
#include "style-border.h"
#include "style-color.h"
27

28 29 30 31
struct closure_colrow_resize {
	gboolean	 is_cols;
	ColRowIndexList *selection;
};
32

33
static gboolean
Jody Goldberg's avatar
Jody Goldberg committed
34
cb_colrow_collect (SheetView *sv, GnmRange const *r, gpointer user_data)
35 36 37 38 39 40 41 42 43 44
{
	struct closure_colrow_resize *info = user_data;
	int first, last;

	if (info->is_cols) {
		first = r->start.col;
		last = r->end.col;
	} else {
		first = r->start.row;
		last = r->end.row;
45
	}
Jody Goldberg's avatar
Jody Goldberg committed
46

47
	info->selection = colrow_get_index_list (first, last, info->selection);
48
	return TRUE;
49 50 51
}

void
52 53
workbook_cmd_resize_selected_colrow (WorkbookControl *wbc, Sheet *sheet,
				     gboolean is_cols, int new_size_pixels)
54 55
{
	struct closure_colrow_resize closure;
56
	closure.is_cols = is_cols;
57
	closure.selection = NULL;
Jody Goldberg's avatar
Jody Goldberg committed
58 59
	selection_foreach_range (sheet_get_view (sheet, wb_control_view (wbc)),
				 TRUE, &cb_colrow_collect, &closure);
60
	cmd_resize_colrow (wbc, sheet, is_cols, closure.selection, new_size_pixels);
61
}