Commit 3c68863f authored by Morten Welinder's avatar Morten Welinder

Workbook: avoid some inclusion of workbook-priv.h

parent fe0bd4c3
2011-05-22 Morten Welinder <terra@gnome.org>
* src/workbook.h (WORKBOOK_FOREACH_SHEET): Move from
workbook-priv.h
2011-05-21 Morten Welinder <terra@gnome.org>
* src/expr-name.c (expr_name_set_pos): Rename from
......
......@@ -22,7 +22,7 @@
#include <sheet.h>
#include <gutils.h>
#include <workbook-priv.h>
#include <workbook.h>
#include <func.h>
#include <value.h>
#include <cell.h>
......
2011-05-22 Morten Welinder <terra@gnome.org>
* openoffice-write.c (odf_write_content): Remove test for
always-true condition. If we must have that check, it should
check for an active global name that we intend to write.
2011-05-21 Morten Welinder <terra@gnome.org>
* openoffice-read.c (odf_fix_en_apply): Use expr_name_set_name.
......
......@@ -29,7 +29,6 @@
#include <gnm-plugin.h>
#include <workbook-view.h>
#include <workbook.h>
#include <workbook-priv.h>
#include <sheet.h>
#include <sheet-merge.h>
#include <sheet-filter.h>
......@@ -1287,18 +1286,20 @@ odf_fix_expr_names_t_add (odf_fix_expr_names_t *fen, char const *orig, char *fix
static gboolean
odf_fix_en_validate (char const *name, odf_fix_expr_names_t *fen)
{
GSList *sheets;
if (!expr_name_validate (name))
return FALSE;
if (NULL != g_hash_table_lookup (fen->fixed2orig, name))
return FALSE;
if (NULL != gnm_named_expr_collection_lookup (fen->state->pos.wb->names, name))
return FALSE;
for (sheets = workbook_sheets (fen->state->pos.wb); sheets != NULL; sheets = sheets->next)
if (NULL != gnm_named_expr_collection_lookup
(((Sheet *)(sheets->data))->names, name))
return FALSE;
WORKBOOK_FOREACH_SHEET
(fen->state->pos.wb, sheet,
{
GnmParsePos pp;
parse_pos_init_sheet (&pp, sheet);
if (expr_name_lookup (&pp, name))
return FALSE;
});
return TRUE;
}
......@@ -1339,20 +1340,9 @@ static void
odf_fix_expr_names (OOParseState *state)
{
odf_fix_expr_names_t *fen = odf_fix_expr_names_t_new (state);
GSList *sheets = workbook_sheets (state->pos.wb), *l;
g_hash_table_foreach (state->pos.wb->names->names,
(GHFunc)odf_fix_en_collect, fen);
g_hash_table_foreach (state->pos.wb->names->placeholders,
(GHFunc)odf_fix_en_collect, fen);
for (l = sheets; l != NULL; l = l->next) {
Sheet *sheet = l->data;
g_hash_table_foreach (sheet->names->names,
(GHFunc) odf_fix_en_collect, fen);
g_hash_table_foreach (sheet->names->placeholders,
(GHFunc) odf_fix_en_collect, fen);
}
workbook_foreach_name (state->pos.wb, FALSE,
(GHFunc)odf_fix_en_collect, fen);
workbook_foreach_name (state->pos.wb, FALSE,
(GHFunc)odf_fix_en_apply, fen->orig2fixed);
......
......@@ -4268,13 +4268,13 @@ odf_write_content (GnmOOExport *state, GsfOutput *child)
has_autofilters |= (sheet->filters != NULL);
odf_update_progress (state, state->sheet_progress);
}
if (state->wb->names != NULL) {
gsf_xml_out_start_element (state->xml, TABLE "named-expressions");
workbook_foreach_name
(state->wb, (get_gsf_odf_version () > 101),
(GHFunc)&odf_write_named_expression, state);
gsf_xml_out_end_element (state->xml); /* </table:named-expressions> */
}
gsf_xml_out_start_element (state->xml, TABLE "named-expressions");
workbook_foreach_name
(state->wb, (get_gsf_odf_version () > 101),
(GHFunc)&odf_write_named_expression, state);
gsf_xml_out_end_element (state->xml); /* </table:named-expressions> */
if (has_autofilters) {
gsf_xml_out_start_element (state->xml, TABLE "database-ranges");
for (i = 0; i < workbook_sheet_count (state->wb); i++) {
......
......@@ -29,12 +29,12 @@
#include "help.h"
#include <gui-util.h>
#include <workbook-priv.h> /* for Workbook::names */
#include <workbook-control.h>
#include <ranges.h>
#include <value.h>
#include <expr-name.h>
#include <sheet.h>
#include <workbook.h>
#include <workbook-view.h>
#include <wbc-gtk.h>
......@@ -138,6 +138,9 @@ cb_load_names (G_GNUC_UNUSED gpointer key,
GtkTreeIter iter;
gboolean is_address = gnm_expr_top_is_rangeref (nexpr->texpr);
if (expr_name_is_placeholder (nexpr))
return;
if (is_address) {
gtk_tree_store_append (user->state->model, &iter, &user->iter);
gtk_tree_store_set (user->state->model, &iter,
......@@ -165,9 +168,8 @@ dialog_goto_load_names (GotoState *state)
SHEET_POINTER, NULL,
EXPRESSION, NULL,
-1);
if (state->wb->names != NULL)
g_hash_table_foreach (state->wb->names->names,
(GHFunc) cb_load_names, &closure);
workbook_foreach_name (state->wb, FALSE,
(GHFunc)cb_load_names, &closure);
l = workbook_sheet_count (state->wb);
for (i = 0; i < l; i++) {
......@@ -179,12 +181,7 @@ dialog_goto_load_names (GotoState *state)
SHEET_POINTER, sheet,
EXPRESSION, NULL,
-1);
if (sheet->names != NULL)
g_hash_table_foreach (sheet->names->names,
(GHFunc) cb_load_names, &closure);
}
}
static void
......
......@@ -730,6 +730,9 @@ expr_name_set_name (GnmNamedExpr *nexpr,
if (go_str_compare (new_name, old_name) == 0)
return FALSE;
#if 1
g_printerr ("Renaming %s to %s\n", old_name, new_name);
#endif
h = nexpr->scope
? (nexpr->is_placeholder
? nexpr->scope->placeholders
......
......@@ -36,7 +36,7 @@
#include "parse-util.h"
#include "ranges.h"
#include "number-match.h"
#include "workbook-priv.h"
#include "workbook.h"
#include "gutils.h"
#include "parse-util.h"
#include "mathfunc.h"
......
......@@ -27,7 +27,6 @@
#include "session.h"
#include "application.h"
#include <workbook.h>
#include <workbook-priv.h>
#include <workbook-view.h>
#include <wbc-gtk.h>
#include <gui-file.h>
......
......@@ -48,7 +48,7 @@
#include "sheet-control-gui-priv.h"
#include "sheet-view.h"
#include "cmd-edit.h"
#include "workbook-priv.h"
#include "workbook.h"
#include "workbook-view.h"
#include "wbc-gtk-impl.h"
#include "workbook-cmd-format.h"
......
......@@ -68,16 +68,6 @@ do { \
WORKBOOK_FOREACH_VIEW((wb), view, \
WORKBOOK_VIEW_FOREACH_CONTROL(view, control, code);)
#define WORKBOOK_FOREACH_SHEET(wb, sheet, code) \
do { \
unsigned _sheetno; \
for (_sheetno = 0; _sheetno < (wb)->sheets->len; _sheetno++) { \
Sheet *sheet = g_ptr_array_index ((wb)->sheets, _sheetno); \
code; \
} \
} while (0)
/*
* Walk the dependents. WARNING: Note, that it is only valid to muck with
* the current dependency in the code.
......
......@@ -90,6 +90,18 @@ int workbook_sheet_state_size (WorkbookSheetState const *wss);
char *workbook_sheet_state_diff (WorkbookSheetState const *wss_a,
WorkbookSheetState const *wss_b);
#define WORKBOOK_FOREACH_SHEET(wb, sheet, code) \
do { \
const Workbook *wb_ = (wb); \
unsigned sheetno_; \
unsigned sheetcount_ = workbook_sheet_count (wb_); \
for (sheetno_ = 0; sheetno_ < sheetcount_; sheetno_++) { \
Sheet *sheet = workbook_sheet_by_index (wb_, sheetno_); \
code; \
} \
} while (0)
G_END_DECLS
#endif /* _GNM_WORKBOOK_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment