aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frame.c77
-rw-r--r--src/presentation.c26
-rw-r--r--src/stylesheet.c7
-rw-r--r--src/stylesheet.h2
4 files changed, 104 insertions, 8 deletions
diff --git a/src/frame.c b/src/frame.c
index 4fa7531..e25b64f 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -86,6 +86,80 @@ struct frame *add_subframe(struct frame *fr)
}
+static void parse_option(struct frame *fr, const char *opt)
+{
+ printf("Option '%s'\n", opt);
+
+ if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL)
+ && (index(opt, '+') != rindex(opt, '+')) )
+ {
+ char *w;
+ char *h;
+ char *x;
+ char *y;
+
+ /* Looks like a dimension/position thing */
+ w = strdup(opt);
+ h = index(w, 'x');
+ h[0] = '\0'; h++;
+
+ x = index(h, '+');
+ if ( x == NULL ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ x[0] = '\0'; x++;
+
+ y = index(x, '+');
+ if ( x == NULL ) {
+ fprintf(stderr, "Invalid option '%s'\n", opt);
+ return;
+ }
+ y[0] = '\0'; y++;
+
+ printf("'%s' x '%s' + '%s' + '%s'\n", w, h, x, y);
+ /* FIXME: Parse length/unit couples */
+ /* FIXME: Turn x and y into numbers */
+
+ free(w);
+ }
+
+ /* FIXME: Handle styles */
+}
+
+
+static void parse_options(struct frame *fr, const char *opth)
+{
+ int i;
+ size_t len;
+ size_t start;
+ char *opt = strdup(opth);
+
+ printf("Processing options '%s'\n", opt);
+
+ len = strlen(opt);
+ start = 0;
+
+ for ( i=0; i<len; i++ ) {
+
+ /* FIXME: comma might be escaped or quoted */
+ if ( opt[i] == ',' ) {
+ opt[i] = '\0';
+ parse_option(fr, opt+start);
+ start = i+1;
+ }
+
+ }
+
+ if ( start != len ) {
+ parse_option(fr, opt+start);
+ }
+
+ free(opt);
+ printf("Done.\n");
+}
+
+
static int recursive_unpack(struct frame *fr, const char *sc)
{
SCBlockList *bl;
@@ -100,7 +174,10 @@ static int recursive_unpack(struct frame *fr, const char *sc)
b = sc_block_list_next(bl, iter) )
{
struct frame *sfr;
+
sfr = add_subframe(fr);
+ parse_options(sfr, b->options);
+
sfr->sc = remove_blocks(b->contents, "f");
if ( recursive_unpack(sfr, b->contents) ) {
sc_block_list_free(bl);
diff --git a/src/presentation.c b/src/presentation.c
index 5e3ba19..8831c03 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -255,7 +255,17 @@ struct presentation *new_presentation()
}
-static char *packed_sc(struct frame *fr)
+static char *maybe_star(int i)
+{
+ if ( i ) {
+ return "*";
+ } else {
+ return "";
+ }
+}
+
+
+static char *packed_sc(struct frame *fr, StyleSheet *ss)
{
char *sc;
int i;
@@ -277,14 +287,20 @@ static char *packed_sc(struct frame *fr)
char *scn;
size_t ch_len;
- ch_sc = packed_sc(fr->children[i]);
+ ch_sc = packed_sc(fr->children[i], ss);
ch_len = strlen(ch_sc);
len += ch_len + 64;
scn = malloc(len + ch_len);
- snprintf(scn, len, "%s\\f[%.1fx%.1f+%.1f+%.1f]{%s}", sc,
- fr->children[i]->lop.w, fr->children[i]->lop.h,
+ snprintf(scn, len,
+ "%s\\f[%.1f%sx%.1f%s+%.1f+%.1f,style=%i%s]{%s}", sc,
+ fr->children[i]->lop.w,
+ units(fr->children[i]->lop.w_units),
+ fr->children[i]->lop.h,
+ units(fr->children[i]->lop.h_units),
fr->children[i]->lop.x, fr->children[i]->lop.y,
+ style_number(ss, fr->style),
+ maybe_star(fr->lop_from_style),
ch_sc);
free(ch_sc);
free(sc);
@@ -337,7 +353,7 @@ int save_presentation(struct presentation *p, const char *filename)
snprintf(s_id, 31, "%i", i);
serialize_start(&ser, s_id);
- sc = packed_sc(s->top);
+ sc = packed_sc(s->top, p->ss);
serialize_s(&ser, "sc", sc);
free(sc);
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 9246cbf..f4b7c39 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -349,7 +349,7 @@ StyleSheet *load_stylesheet(const char *filename)
}
-static const char *units(LengthUnits un)
+const char *units(LengthUnits un)
{
switch ( un ) {
case UNITS_SLIDE : return "u";
@@ -369,7 +369,7 @@ static void serialize_f_units(struct serializer *s, const char *key, double val,
}
-static int style_number(StyleSheet *ss, struct style *s)
+int style_number(StyleSheet *ss, struct style *s)
{
int i;
@@ -385,6 +385,8 @@ void write_stylesheet(StyleSheet *ss, struct serializer *ser)
{
int i;
+ serialize_i(ser, "default_style", style_number(ss, ss->default_style));
+
serialize_start(ser, "styles");
for ( i=0; i<ss->n_styles; i++ ) {
@@ -438,7 +440,6 @@ void write_stylesheet(StyleSheet *ss, struct serializer *ser)
}
serialize_end(ser);
-
}
diff --git a/src/stylesheet.h b/src/stylesheet.h
index 7b2a846..b7dc210 100644
--- a/src/stylesheet.h
+++ b/src/stylesheet.h
@@ -71,6 +71,8 @@ extern void add_to_template(struct slide_template *t, struct style *sty);
extern int save_stylesheet(StyleSheet *ss, const char *filename);
extern StyleSheet *tree_to_stylesheet(struct ds_node *root);
extern void write_stylesheet(StyleSheet *ss, struct serializer *ser);
+extern const char *units(LengthUnits un);
+extern int style_number(StyleSheet *ss, struct style *s);
typedef struct _styleiterator StyleIterator;
extern struct style *style_first(StyleSheet *ss, StyleIterator **piter);