From 008fde3497c1669f516d6b43f5effd34258b1213 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 15 Aug 2011 21:25:57 +0200 Subject: Add loading and saving stuff --- src/loadsave.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/loadsave.c (limited to 'src/loadsave.c') diff --git a/src/loadsave.c b/src/loadsave.c new file mode 100644 index 0000000..27476a0 --- /dev/null +++ b/src/loadsave.c @@ -0,0 +1,102 @@ +/* + * loadsave.v + * + * Colloquium - A tiny presentation program + * + * Copyright (c) 2011 Thomas White + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include "presentation.h" +#include "objects.h" +#include "stylesheet.h" + + +int load_presentation(struct presentation *p, const char *filename) +{ + return 0; +} + + +static const char *type_text(enum objtype t) +{ + switch ( t ) + { + case TEXT : return "text"; + default : return "unknown"; + } +} + + +static void write_stylesheet(StyleSheet *ss, FILE *fh) +{ +} + + +int save_presentation(struct presentation *p, const char *filename) +{ + FILE *fh; + int i; + + fh = fopen(filename, "w"); + if ( fh == NULL ) return 1; + + fprintf(fh, "# Colloquium presentation file\n"); + fprintf(fh, "version=0\n"); + + write_stylesheet(p->ss, fh); + + for ( i=0; inum_slides; i++ ) { + + int j; + struct slide *s; + + s = p->slides[i]; + + fprintf(fh, "++slide\n"); + fprintf(fh, "width=%.2f\n", s->slide_width); + fprintf(fh, "height=%.2f\n", s->slide_height); + + for ( j=0; jnum_objects; j++ ) { + + struct object *o; + + o = s->objects[j]; + + if ( o->empty ) continue; + + fprintf(fh, "++object\n"); + fprintf(fh, "type=%s\n", type_text(o->type)); + fprintf(fh, "x=%.2f\n", o->x); + fprintf(fh, "y=%.2f\n", o->y); + fprintf(fh, "w=%.2f\n", o->bb_width); + fprintf(fh, "h=%.2f\n", o->bb_height); + fprintf(fh, "--object\n"); + } + + fprintf(fh, "--slide\n"); + + } + + fclose(fh); + return 0; +} -- cgit v1.2.3