Commit e175d83a authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

port to libxml2 and begin merging into here.

2002-02-01  Jody Goldberg <jody@gnome.org>

	* src/xml-io-autoft.c : port to libxml2 and begin merging into
	* src/format-template.c : here.
parent dbab3705
2002-02-01 Jody Goldberg <jody@gnome.org>
* src/xml-io-autoft.c : port to libxml2 and begin merging into
* src/format-template.c : here.
2002-01-31 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-util.c (gnumeric_dialog_question_yes_no) : port to gnome2
......
2002-02-01 Jody Goldberg <jody@gnome.org>
* src/xml-io-autoft.c : port to libxml2 and begin merging into
* src/format-template.c : here.
2002-01-31 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-util.c (gnumeric_dialog_question_yes_no) : port to gnome2
......
2002-02-01 Jody Goldberg <jody@gnome.org>
* src/xml-io-autoft.c : port to libxml2 and begin merging into
* src/format-template.c : here.
2002-01-31 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/gui-util.c (gnumeric_dialog_question_yes_no) : port to gnome2
......
......@@ -106,7 +106,7 @@ cell_copy (Cell const *cell)
/* The new cell is not linked into any of the major management structures */
new_cell->base.sheet = NULL;
new_cell->base.flags &= ~(DEPENDENT_NEEDS_RECALC|CELL_IN_SHEET_LIST|DEPENDENT_IN_EXPR_LIST);
new_cell->base.flags &= ~(DEPENDENT_NEEDS_RECALC|CELL_IN_SHEET_LIST|DEPENDENT_IS_LINKED);
/* now copy properly the rest */
if (cell_has_expr (new_cell))
......
......@@ -16,7 +16,7 @@ typedef enum {
CELL_IS_MERGED = 0x040000,
/* Cell is in the midst of a cyclic calculation */
CELL_BEING_ITERATED = 0x080000,
CELL_BEING_ITERATED = 0x080000, /* TODO : move to dependent */
/* Cell content spans */
CELL_CONTENT_SPANS = 0x100000
......@@ -56,7 +56,7 @@ gboolean cell_eval_content (Cell *cell);
* Cell state checking
*/
#define cell_needs_recalc(cell) ((cell)->base.flags & DEPENDENT_NEEDS_RECALC)
#define cell_expr_is_linked(cell) ((cell)->base.flags & DEPENDENT_IN_EXPR_LIST)
#define cell_expr_is_linked(cell) ((cell)->base.flags & DEPENDENT_IS_LINKED)
#define cell_has_expr(cell) ((cell)->base.flags & CELL_HAS_EXPRESSION)
#define cell_is_linked(cell) ((cell)->base.flags & CELL_IN_SHEET_LIST)
#define cell_is_merged(cell) ((cell)->base.flags & CELL_IS_MERGED)
......
......@@ -2867,10 +2867,10 @@ typedef struct {
Sheet *sheet;
GSList *selection; /* Selections on the sheet */
GSList *selection; /* Selections on the sheet */
GSList *old_styles; /* Older styles, one style_list per selection range*/
FormatTemplate *ft; /* Template that has been applied */
FormatTemplate const *ft; /* Template that has been applied */
} CmdAutoFormat;
GNUMERIC_MAKE_COMMAND (CmdAutoFormat, cmd_autoformat);
......@@ -2953,7 +2953,7 @@ cmd_autoformat_finalize (GObject *cmd)
* Return value: TRUE if there was a problem
**/
gboolean
cmd_autoformat (WorkbookControl *wbc, Sheet *sheet, FormatTemplate *ft)
cmd_autoformat (WorkbookControl *wbc, Sheet *sheet, FormatTemplate const *ft)
{
GObject *obj;
CmdAutoFormat *me;
......@@ -2963,7 +2963,7 @@ cmd_autoformat (WorkbookControl *wbc, Sheet *sheet, FormatTemplate *ft)
g_return_val_if_fail (IS_SHEET (sheet), TRUE);
l = selection_get_ranges (sheet, FALSE); /* Regions may overlap */
if (!format_template_check_valid (ft, l)) {
if (!format_template_check_valid (ft, l, COMMAND_CONTEXT (wbc))) {
range_fragment_free (l);
return TRUE;
}
......
......@@ -6,7 +6,6 @@
#include "consolidate.h"
#include "gnumeric.h"
#include "format-template.h"
#include "sort.h"
void command_undo (WorkbookControl *wbc);
......@@ -61,7 +60,8 @@ gboolean cmd_autofill (WorkbookControl *wbc, Sheet *sheet,
gboolean cmd_clear_selection (WorkbookControl *wbc, Sheet *sheet,
int clear_flags);
gboolean cmd_autoformat (WorkbookControl *wbc, Sheet *sheet, FormatTemplate *ft);
gboolean cmd_autoformat (WorkbookControl *wbc, Sheet *sheet,
FormatTemplate const *ft);
gboolean cmd_colrow_hide_selection (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, gboolean visible);
......
2002-02-02 Jody Goldberg <jody@gnome.org>
* src/dialogs/dialog-autoformat.c : an initial port to gnome2
and guru-ification.
2002-02-02 Andreas J. Guelzow <aguelzow@taliesin.ca>
* plugin-manager.glade : replace last clist with gtktreeview
......@@ -5,7 +10,6 @@
gtktreeview
(dialog_plugin_manager) : move from clist to treeview
(update_plugin_details_view) : ditto
2002-01-31 Andreas J. Guelzow <aguelzow@taliesin.ca>
......
......@@ -29,7 +29,7 @@
<child>
<widget class="GtkButton" id="format_ok">
<property name="can_default">yes</property>
<property name="has_default">yes</property>
<!-- <property name="has_default">yes</property> libglade problem -->
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label" translatable="yes">gtk-ok</property>
......@@ -101,8 +101,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item2_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget1">
<property name="label" translatable="yes">Apply _Number Formats</property>
......@@ -121,8 +119,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item3_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget2">
<property name="label" translatable="yes">Apply _Borders</property>
......@@ -141,8 +137,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item4_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget3">
<property name="label" translatable="yes">Apply _Fonts</property>
......@@ -161,8 +155,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item5_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget4">
<property name="label" translatable="yes">Apply _Patterns</property>
......@@ -181,8 +173,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item6_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget5">
<property name="label" translatable="yes">Apply _Alignment</property>
......@@ -207,8 +197,6 @@
<property name="always_show_toggle">yes</property>
<property name="visible">yes</property>
<signal name="activate" handler="on_item8_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget6">
<property name="label" translatable="yes">_Show Gridlines</property>
......@@ -236,9 +224,7 @@
<child>
<widget class="GtkImageMenuItem" id="format_new">
<property name="visible">yes</property>
<signal name="activate" handler="on_new1_activate" />
<property name="visible">no</property>
<child internal-child="image">
<widget class="GtkImage" id="convertwidget7">
......@@ -261,9 +247,7 @@
<child>
<widget class="GtkMenuItem" id="format_edit">
<property name="visible">yes</property>
<signal name="activate" handler="on_edit1_activate" />
<property name="visible">no</property>
<child>
<widget class="GtkAccelLabel" id="convertwidget9">
......@@ -281,8 +265,6 @@
<widget class="GtkMenuItem" id="format_remove_current">
<property name="visible">yes</property>
<signal name="activate" handler="on_remove_current1_activate" />
<child>
<widget class="GtkAccelLabel" id="convertwidget10">
<property name="label" translatable="yes">_Remove Current</property>
......
This diff is collapsed.
......@@ -185,7 +185,7 @@ static void cb_up (GtkWidget *w, SheetManager *state) { move_cb (state, -1); }
static void cb_down (GtkWidget *w, SheetManager *state) { move_cb (state, 1); }
static void
close_clicked_cb (GtkWidget *ignore, SheetManager *state)
cb_close_clicked (GtkWidget *ignore, SheetManager *state)
{
gtk_widget_destroy (GTK_WIDGET (state->dialog));
}
......@@ -230,7 +230,7 @@ dialog_sheet_order (WorkbookControlGUI *wbcg)
GTK_SIGNAL_FUNC (cb_down), state);
gtk_signal_connect (GTK_OBJECT (state->close_btn),
"clicked",
GTK_SIGNAL_FUNC (close_clicked_cb), state);
GTK_SIGNAL_FUNC (cb_close_clicked), state);
/* a candidate for merging into attach guru */
gtk_signal_connect (GTK_OBJECT (state->dialog),
......
This diff is collapsed.
......@@ -39,33 +39,63 @@
* 1. Can be 0 or greater. Specifies the number of rows to at least
* not but a repetetive style calculated from the far side.
* ----------------
*
*/
typedef struct {
/*
* Placement (These form the top, left coordinates)
*/
int offset; /* Offset (top/left) */
int offset_gravity; /* Gravity +1 means relative to top/left, -1 relative to bottom/right */
/*
* Dimensions (These form the bottom right coordinates)
*/
int size;
int offset; /* Offset (top/left) */
int offset_gravity; /* Gravity +1 means relative to top/left, -1 relative to bottom/right */
int size; /* Dimensions (These form the bottom right coordinates) */
} FormatColRowInfo;
/* WARNING : do not change these or persistence will break */
typedef enum {
FREQ_DIRECTION_NONE,
FREQ_DIRECTION_HORIZONTAL,
FREQ_DIRECTION_VERTICAL
} FreqDirection;
typedef struct {
GList *categories;
gchar *orig_name, *name;
gchar *description;
gint lang_score;
} FormatTemplateCategoryGroup;
typedef struct {
char *directory;
char *orig_name, *name;
char *description;
int lang_score;
gboolean is_writable;
} FormatTemplateCategory;
struct _FormatTemplate {
FormatTemplateCategory *category;
GSList *members; /* the actual TemplateMembers */
char *filename;
char *author;
char *name;
char *description;
/* what to enable */
gboolean number : 1;
gboolean border : 1;
gboolean font : 1;
gboolean patterns : 1;
gboolean alignment : 1;
/* <private> */
/* pre-calculate styles */
GHashTable *table;
gboolean invalidate_hash;
Range dimension;
};
typedef struct {
FormatColRowInfo row; /* Row info */
FormatColRowInfo col; /* Col info */
/*
* Frequency (How many times to repeat) and in which
/* Frequency (How many times to repeat) and in which
* direction and when to stop.
*/
FreqDirection direction;
......@@ -76,102 +106,16 @@ typedef struct {
MStyle *mstyle; /* Style to apply */
} TemplateMember;
typedef struct _FormatTemplateCategory FormatTemplateCategory;
typedef struct _FormatTemplateCategoryGroup FormatTemplateCategoryGroup;
typedef struct {
/* The filename of this template */
GString *filename;
/*
* Some usual information
*/
GString *author;
GString *name;
GString *description;
/*
* The most important thing the actual TemplateMembers are
* stored in this singly-linked-list.
*/
GSList *members;
/*
* Command context for some error reporting
*/
CommandContext *context;
/*
* What to filter
*/
gboolean number, border, font, patterns, alignment;
/*
* The hashtable used to pre-calculate styles
*/
GHashTable *table;
gboolean invalidate_hash;
Range dimension;
/*
* Category it came from.
*/
FormatTemplateCategory *category;
} FormatTemplate;
struct _FormatTemplateCategory {
gchar *directory;
gchar *orig_name, *name;
gchar *description;
gint lang_score;
gboolean is_writable;
};
struct _FormatTemplateCategoryGroup {
GList *categories;
gchar *orig_name, *name;
gchar *description;
gint lang_score;
};
/*
* Functions for FormatColRowInfo
*/
FormatColRowInfo format_col_row_info_make (int offset, int offset_gravity,
int size);
/*
* Functions for TemplateMember
*/
TemplateMember *format_template_member_new (void);
TemplateMember *format_template_member_clone (TemplateMember *member);
void format_template_member_free (TemplateMember *member);
FormatColRowInfo format_template_member_get_row_info (TemplateMember *member);
FormatColRowInfo format_template_member_get_col_info (TemplateMember *member);
FreqDirection format_template_member_get_direction (TemplateMember *member);
int format_template_member_get_repeat (TemplateMember *member);
int format_template_member_get_skip (TemplateMember *member);
int format_template_member_get_edge (TemplateMember *member);
MStyle *format_template_member_get_style (TemplateMember *member);
void format_template_member_set_row_info (TemplateMember *member, FormatColRowInfo row_info);
void format_template_member_set_col_info (TemplateMember *member, FormatColRowInfo col_info);
void format_template_member_set_direction (TemplateMember *member, FreqDirection direction);
void format_template_member_set_repeat (TemplateMember *member, int repeat);
void format_template_member_set_skip (TemplateMember *member, int skip);
void format_template_member_set_edge (TemplateMember *member, int edge);
void format_template_member_set_style (TemplateMember *member, MStyle *mstyle);
/*
* Functions for FormatTemplate
*/
FormatTemplate *format_template_new (CommandContext *context);
FormatTemplate *format_template_clone (FormatTemplate *ft);
void format_template_free (FormatTemplate *ft);
FormatTemplate *format_template_new_from_file (CommandContext *context, const char *filename);
int format_template_save (FormatTemplate *ft);
void format_template_free (FormatTemplate *ft);
FormatTemplate *format_template_clone (FormatTemplate *ft);
FormatTemplate *format_template_new (void);
FormatTemplate *format_template_new_from_file (char const *filename,
CommandContext *context);
gboolean format_template_save (FormatTemplate const *ft,
CommandContext *cc);
gint format_template_compare_name (gconstpointer a, gconstpointer b);
......@@ -179,25 +123,11 @@ void format_template_attach_member (FormatTemplate *
void format_template_detach_member (FormatTemplate *ft, TemplateMember *member);
MStyle *format_template_get_style (FormatTemplate *ft, int row, int col);
void format_template_apply_to_sheet_regions (FormatTemplate *ft, Sheet *sheet, GSList *regions);
gboolean format_template_check_valid (FormatTemplate *ft, GSList *regions);
char *format_template_get_filename (FormatTemplate *ft);
char *format_template_get_name (FormatTemplate *ft);
char *format_template_get_author (FormatTemplate *ft);
char *format_template_get_description (FormatTemplate *ft);
GSList *format_template_get_members (FormatTemplate *ft);
FormatTemplateCategory *format_template_get_category (FormatTemplate *ft);
void format_template_set_filename (FormatTemplate *ft, const char *filename);
void format_template_set_name (FormatTemplate *ft, const char *name);
void format_template_set_author (FormatTemplate *ft, const char *author);
void format_template_set_description (FormatTemplate *ft, const char *description);
void format_template_set_category (FormatTemplate *ft, FormatTemplateCategory *category);
void format_template_set_filter (FormatTemplate *ft,
gboolean number, gboolean border,
gboolean font, gboolean patterns,
gboolean alignment);
void format_template_set_size (FormatTemplate *ft,
int x1, int y1, int x2, int y2);
gboolean format_template_check_valid (FormatTemplate *ft, GSList *regions,
CommandContext *cc);
void format_template_set_name (FormatTemplate *ft, char const *name);
void format_template_set_author (FormatTemplate *ft, char const *author);
void format_template_set_description (FormatTemplate *ft, char const *description);
#endif /* GNUMERIC_FORMAT_TEMPLATE_H */
......@@ -90,6 +90,7 @@ typedef struct _StyleColor StyleColor;
typedef struct _StyleBorder StyleBorder;
typedef struct _StyleRow StyleRow;
typedef struct _StyleCondition StyleCondition;
typedef struct _FormatTemplate FormatTemplate;
typedef struct _Validation Validation;
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* xml-io-autoft.c : Read/Write Format templates using xml encoding.
*
......@@ -32,7 +33,6 @@
#include "plugin-util.h"
#include "mstyle.h"
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlmemory.h>
#include <libgnome/gnome-i18n.h>
......@@ -42,423 +42,17 @@
#define CATEGORY_FILE_NAME ".category"
/*
* Create an XML subtree of doc equivalent to the given FormatColRowInfo
*/
static void
xml_write_format_col_row_info (XmlParseContext *ctxt, FormatColRowInfo info, xmlNodePtr node)
{
xmlNodePtr child;
/*
* Write placement
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Placement", NULL);
xml_node_set_int (child, "offset", info.offset);
xml_node_set_int (child, "offset_gravity", info.offset_gravity);
xmlAddChild (node, child);
/*
* Write dimensions
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Dimensions", NULL);
xml_node_set_int (child, "size", info.size);
xmlAddChild (node, child);
}
/*
* Create an XML subtree of doc equivalent to the given TemplateMember
*/
static xmlNodePtr
xml_write_format_template_member (XmlParseContext *ctxt, TemplateMember *member)
{
xmlNodePtr child;
xmlNodePtr cur;
/*
* General information about member
*/
cur = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Member", NULL);
if (cur == NULL)
return NULL;
/*
* Write row and col info
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Row", NULL);
xml_write_format_col_row_info (ctxt, format_template_member_get_row_info (member), child);
xmlAddChild (cur, child);
child = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Col", NULL);
xml_write_format_col_row_info (ctxt, format_template_member_get_col_info (member), child);
xmlAddChild (cur, child);
/*
* Write frequency information
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, (xmlChar *)"Frequency", NULL);
xml_node_set_int (child, "direction", format_template_member_get_direction (member));
xml_node_set_int (child, "repeat", format_template_member_get_repeat (member));
xml_node_set_int (child, "skip", format_template_member_get_skip (member));
xml_node_set_int (child, "edge", format_template_member_get_edge (member));
xmlAddChild (cur, child);
/*
* Write style
*/
child = xml_write_style (ctxt, format_template_member_get_style (member));
xmlAddChild (cur, child);
return cur;
}
/*
* Create an XML subtree of doc equivalent to the given FormatTemplate
*/
static xmlNodePtr
xml_write_format_template_members (XmlParseContext *ctxt, FormatTemplate *ft)
{
xmlNodePtr root;
xmlNsPtr gmr;
xmlNodePtr child;
GSList *members;
char *author_c, *name_c, *description_c;
/*
* General information about the Template
*/
root = xmlNewDocNode (ctxt->doc, NULL, (xmlChar *)"FormatTemplate", NULL);
if (root == NULL)
return NULL;
gmr = xmlNewNs (root, (xmlChar *)"http://www.gnome.org/gnumeric/format-template/v1", (xmlChar *)"gmr");
xmlSetNs(root, gmr);
ctxt->ns = gmr;
child = xmlNewChild (root, gmr, (xmlChar *)"Information", NULL);
author_c = format_template_get_author (ft);
name_c = format_template_get_name (ft);
description_c = format_template_get_description (ft);
xml_node_set_cstr (child, "author", author_c);
xml_node_set_cstr (child, "name", name_c);
xml_node_set_cstr (child, "description", description_c);
g_free (author_c);
g_free (name_c);
g_free (description_c);
/*
* Write members
*/
child = xmlNewChild (root, gmr, (xmlChar *)"Members", NULL);
members = format_template_get_members (ft);
while (members) {
TemplateMember *member = members->data;
xmlNodePtr c;
c = xml_write_format_template_member (ctxt, member);
xmlAddChild (child, c);
members = g_slist_next (members);
}
return root;
}
/*
* Save a Template in an XML file
* One build an in-memory XML tree and save it to a file.
* returns 0 in case of success, -1 otherwise.