--- psiconv/trunk/program/psiconv/gen_xhtml.c 2004/01/26 21:56:49 190
+++ psiconv/trunk/program/psiconv/gen_xhtml.c 2004/02/04 11:35:35 195
@@ -21,9 +21,11 @@
#include base_paragraph->bullet->on?"
",enc);
+ else if ((data[i] == 0x0b) || (data[i] == 0x0c))
+ output_simple_chars(config,list,"-",enc);
+ else if ((data[i] == 0x0f) || (data[i] == 0x09) || (data[i] == 0x0a))
+ output_simple_chars(config,list," ",enc);
+ else if (data[i] >= 0x20)
+ output_char(config,list,data[i],enc);
+ }
+}
+
void color(const psiconv_config config, psiconv_list list,
psiconv_color color,int may_be_transparant, const encoding enc)
{
@@ -49,6 +121,19 @@
}
}
+void border(const psiconv_config config, psiconv_list list,
+ psiconv_border_kind_t border,const encoding enc)
+{
+ output_simple_chars(config,list,
+ border == psiconv_border_none?"none":
+ border == psiconv_border_solid?"solid":
+ border == psiconv_border_double?"double":
+ border == psiconv_border_dotted?"dotted":
+ border == psiconv_border_dashed?"dashed":
+ border == psiconv_border_dotdashed?"dashed":
+ border == psiconv_border_dotdotdashed?"dashed":"",enc);
+}
+
void style_name(const psiconv_config config, psiconv_list list,
const psiconv_string_t name,const encoding enc)
{
@@ -71,6 +156,26 @@
free(name_copy);
}
+/* Check whether the same layout information would be generated */
+int character_layout_equal(const psiconv_character_layout l1,
+ const psiconv_character_layout l2)
+{
+ return (l1 && l2 &&
+ (l1->color->red == l2->color->red) &&
+ (l1->color->green == l2->color->green) &&
+ (l1->color->blue == l2->color->blue) &&
+ (l1->back_color->red == l2->back_color->red) &&
+ (l1->back_color->green == l2->back_color->green) &&
+ (l1->back_color->blue == l2->back_color->blue) &&
+ (l1->font_size == l2->font_size) &&
+ (l1->italic == l2->italic) &&
+ (l1->bold == l2->bold) &&
+ (l1->super_sub == l2->super_sub) &&
+ (l1->underline == l2->underline) &&
+ (l1->strikethrough == l2->strikethrough) &&
+ (l1->font->screenfont == l2->font->screenfont));
+}
+
void character_layout_diffs(const psiconv_config config, psiconv_list list,
const psiconv_character_layout new,
const psiconv_character_layout base,
@@ -78,33 +183,6 @@
{
char tempstr[TEMPSTR_LEN];
- if (!base || (new->italic != base->italic)) {
- output_simple_chars(config,list,"font-style:",enc);
- output_simple_chars(config,list,new->italic?"italic":"normal",enc);
- output_simple_chars(config,list,";",enc);
- }
- if (!base || (new->underline != base->underline) ||
- (new->strikethrough != base->strikethrough)) {
- output_simple_chars(config,list,"text-decoration:",enc);
- output_simple_chars(config,list,new->underline?"underline":
- new->strikethrough?"line-through":
- "none",enc);
- output_simple_chars(config,list,";",enc);
- }
- if (!base || (new->bold != base->bold)) {
- output_simple_chars(config,list,"font-weight:",enc);
- output_simple_chars(config,list,new->bold?"bold":"normal",enc);
- output_simple_chars(config,list,";",enc);
- }
- if (!base || (new->super_sub != base->super_sub)) {
- output_simple_chars(config,list,"font-style:",enc);
- output_simple_chars(config,list,
- new->super_sub==psiconv_superscript?"super":
- new->super_sub==psiconv_subscript?"sub":
- "normal",enc);
- output_simple_chars(config,list,";",enc);
- }
-
if (!base || (new->color->red != base->color->red) ||
(new->color->green != base->color->green) ||
(new->color->blue != base->color->blue)) {
@@ -127,6 +205,42 @@
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
+
+ if (!base || (new->italic != base->italic)) {
+ output_simple_chars(config,list,"font-style:",enc);
+ output_simple_chars(config,list,new->italic?"italic":"normal",enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->bold != base->bold)) {
+ output_simple_chars(config,list,"font-weight:",enc);
+ output_simple_chars(config,list,new->bold?"bold":"normal",enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->super_sub != base->super_sub)) {
+ output_simple_chars(config,list,"font-style:",enc);
+ output_simple_chars(config,list,
+ new->super_sub==psiconv_superscript?"super":
+ new->super_sub==psiconv_subscript?"sub":
+ "normal",enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->underline != base->underline) ||
+ (new->strikethrough != base->strikethrough)) {
+ output_simple_chars(config,list,"text-decoration:",enc);
+ output_simple_chars(config,list,new->underline?"underline":
+ new->strikethrough?"line-through":
+ "none",enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->font->screenfont != base->font->screenfont)) {
+ output_simple_chars(config,list,"font-family:",enc);
+ output_simple_chars(config,list,
+ new->font->screenfont == psiconv_font_serif?"serif":
+ new->font->screenfont == psiconv_font_sansserif?"sans-serif":
+ new->font->screenfont == psiconv_font_nonprop?"monospace":
+ new->font->screenfont == psiconv_font_misc?"fantasy":"",
+ enc);
+ }
}
void paragraph_layout_diffs(const psiconv_config config, psiconv_list list,
@@ -135,6 +249,27 @@
const encoding enc)
{
char tempstr[TEMPSTR_LEN];
+ float pad_left_base=0.0,pad_left_new,text_indent_base=0.0,text_indent_new;
+
+ if (new->bullet->on) {
+ pad_left_new = new->indent_left < new->indent_first?
+ new->indent_left:new->indent_first;
+ text_indent_new = 0.0;
+ } else {
+ pad_left_new = new->indent_left;
+ text_indent_new = new->indent_first;
+ }
+ if (base) {
+ if (base->bullet->on) {
+ pad_left_base = base->indent_left < base->indent_first?
+ base->indent_left:base->indent_first;
+ text_indent_base = 0.0;
+ } else {
+ pad_left_base = base->indent_left;
+ text_indent_base = base->indent_first;
+ }
+ }
+
if (!base || (new->back_color->red != base->back_color->red) ||
(new->back_color->green != base->back_color->green) ||
@@ -144,9 +279,9 @@
output_simple_chars(config,list,";",enc);
}
- if (!base || (new->indent_left != base->indent_left)) {
+ if (!base || (pad_left_new != pad_left_base)) {
output_simple_chars(config,list,"padding-left:",enc);
- snprintf(tempstr,TEMPSTR_LEN,"%f",new->indent_left);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",pad_left_new);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"cm;",enc);
}
@@ -158,10 +293,9 @@
output_simple_chars(config,list,"cm;",enc);
}
- if (!base || (new->indent_left - new->indent_first !=
- base->indent_left - base->indent_first)) {
+ if (!base || (text_indent_new != text_indent_base)) {
output_simple_chars(config,list,"text-indent:",enc);
- snprintf(tempstr,TEMPSTR_LEN,"%f",new->indent_right - new->indent_first);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",text_indent_new);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"cm;",enc);
}
@@ -177,12 +311,15 @@
output_simple_chars(config,list,";",enc);
}
+#if 0
+ /* This gave bad output... */
if (!base || (new->linespacing != base->linespacing)) {
output_simple_chars(config,list,"line-height:",enc);
snprintf(tempstr,TEMPSTR_LEN,"%f",new->linespacing);
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
+#endif
if (!base || (new->space_above != base->space_above)) {
output_simple_chars(config,list,"padding-top:",enc);
@@ -197,7 +334,97 @@
output_simple_chars(config,list,tempstr,enc);
output_simple_chars(config,list,"pt;",enc);
}
-
+
+ if (!base || (new->right_border->kind != base->right_border->kind)) {
+ output_simple_chars(config,list,"border-right-style:",enc);
+ border(config,list,new->right_border->kind,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->bottom_border->kind != base->bottom_border->kind)) {
+ output_simple_chars(config,list,"border-bottom-style:",enc);
+ border(config,list,new->bottom_border->kind,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->top_border->kind != base->top_border->kind)) {
+ output_simple_chars(config,list,"border-top-style:",enc);
+ border(config,list,new->top_border->kind,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base || (new->left_border->kind != base->left_border->kind)) {
+ output_simple_chars(config,list,"border-left-style:",enc);
+ border(config,list,new->left_border->kind,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+
+ if (!base ||
+ ((new->right_border->kind != psiconv_border_none) &&
+ (new->right_border->thickness != base->right_border->thickness))) {
+ output_simple_chars(config,list,"border-right-width:",enc);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",new->right_border->thickness);
+ output_simple_chars(config,list,tempstr,enc);
+ output_simple_chars(config,list,"pt;",enc);
+ }
+ if (!base ||
+ ((new->bottom_border->kind != psiconv_border_none) &&
+ (new->bottom_border->thickness != base->bottom_border->thickness))) {
+ output_simple_chars(config,list,"border-bottom-width:",enc);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",new->bottom_border->thickness);
+ output_simple_chars(config,list,tempstr,enc);
+ output_simple_chars(config,list,"pt;",enc);
+ }
+ if (!base ||
+ ((new->top_border->kind != psiconv_border_none) &&
+ ( new->top_border->thickness != base->top_border->thickness))) {
+ output_simple_chars(config,list,"border-top-width:",enc);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",new->top_border->thickness);
+ output_simple_chars(config,list,tempstr,enc);
+ output_simple_chars(config,list,"pt;",enc);
+ }
+ if (!base ||
+ ((new->left_border->kind != psiconv_border_none) &&
+ (new->left_border->thickness != base->left_border->thickness))) {
+ output_simple_chars(config,list,"border-left-width:",enc);
+ snprintf(tempstr,TEMPSTR_LEN,"%f",new->left_border->thickness);
+ output_simple_chars(config,list,tempstr,enc);
+ output_simple_chars(config,list,"pt;",enc);
+ }
+
+ if (!base ||
+ ((new->right_border->kind != psiconv_border_none) &&
+ ((new->right_border->color->red != base->right_border->color->red) ||
+ (new->right_border->color->green != base->right_border->color->green)||
+ (new->right_border->color->blue != base->right_border->color->blue)))) {
+ output_simple_chars(config,list,"border-right-color:",enc);
+ color(config,list,new->right_border->color,0,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base ||
+ ((new->top_border->kind != psiconv_border_none) &&
+ ((new->top_border->color->red != base->top_border->color->red) ||
+ (new->top_border->color->green != base->top_border->color->green) ||
+ (new->top_border->color->blue != base->top_border->color->blue)))) {
+ output_simple_chars(config,list,"border-top-color:",enc);
+ color(config,list,new->top_border->color,0,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base ||
+ ((new->bottom_border->kind != psiconv_border_none) &&
+ ((new->bottom_border->color->red != base->bottom_border->color->red) ||
+ (new->bottom_border->color->green !=base->bottom_border->color->green)||
+ (new->bottom_border->color->blue != base->bottom_border->color->blue)))){
+ output_simple_chars(config,list,"border-bottom-color:",enc);
+ color(config,list,new->bottom_border->color,0,enc);
+ output_simple_chars(config,list,";",enc);
+ }
+ if (!base ||
+ ((new->left_border->kind != psiconv_border_none) &&
+ ((new->left_border->color->red != base->left_border->color->red) ||
+ (new->left_border->color->green != base->left_border->color->green) ||
+ (new->left_border->color->blue != base->left_border->color->blue)))) {
+ output_simple_chars(config,list,"border-left-color:",enc);
+ color(config,list,new->left_border->color,0,enc);
+ output_simple_chars(config,list,";",enc);
+ }
}
void style(const psiconv_config config, psiconv_list list,
@@ -206,9 +433,9 @@
const psiconv_character_layout base_char,
const encoding enc)
{
- output_simple_chars(config,list,"p[class=\"style_",enc);
+ output_simple_chars(config,list,"*.style_",enc);
style_name(config,list,style->name,enc);
- output_simple_chars(config,list,"\"] {",enc);
+ output_simple_chars(config,list," {",enc);
paragraph_layout_diffs(config,list,style->paragraph,base_para,enc);
character_layout_diffs(config,list,style->character,base_char,enc);
output_simple_chars(config,list,"}\n",enc);
@@ -293,7 +520,7 @@
}
void characters(const psiconv_config config, psiconv_list list,
- const psiconv_string_t text,
+ const psiconv_string_t textstr,
const psiconv_character_layout layout,
const psiconv_character_layout base,
const encoding enc)
@@ -315,7 +542,7 @@
output_simple_chars(config,list,"\">",enc);
}
- output_string(config,list,text,enc);
+ text(config,list,textstr,enc);
if (psiconv_list_length(templist)) {
output_simple_chars(config,list,"",enc);
@@ -329,9 +556,9 @@
const psiconv_word_styles_section styles_sec,
const encoding enc)
{
- int i,charnr;
+ int i,charnr,start,len;
psiconv_string_t text;
- psiconv_in_line_layout layout;
+ psiconv_in_line_layout layout,next_layout;
psiconv_word_style style = NULL;
psiconv_paragraph_layout base_para;
psiconv_character_layout base_char;
@@ -358,7 +585,9 @@
}
}
- output_simple_chars(config,list,"