--- psiconv/trunk/program/psiconv/gen_xhtml.c 2004/01/26 21:56:49 190
+++ psiconv/trunk/program/psiconv/gen_xhtml.c 2004/01/28 20:18:54 191
@@ -31,6 +31,22 @@
#define TEMPSTR_LEN 100
+void text(const psiconv_config config,psiconv_list list,
+ psiconv_string_t data,const encoding enc)
+{
+ int i;
+ for (i = 0; i < psiconv_unicode_strlen(data); i++) {
+ if ((data[i] == 0x06) || (data[i] == 0x07) || (data[i] == 0x08))
+ output_simple_chars(config,list,"
",enc);
+ else if ((data[i] == 0x0b) || (data[i] == 0x0c))
+ output_simple_chars(config,list,"-",enc);
+ else if (data[i] == 0x0f)
+ 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 +65,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)
{
@@ -78,33 +107,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 +129,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 +173,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 +203,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 +217,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);
}
@@ -197,7 +255,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 +354,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 +441,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 +463,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);
@@ -358,7 +506,9 @@
}
}
- output_simple_chars(config,list,"
base_paragraph->bullet->on?"
\n", + enc); if (!styles_sec) { psiconv_free_paragraph_layout(base_para); psiconv_free_character_layout(base_char);