--- abiword-plugins/wp/impexp/OpenWriter/xp/ie_imp_OpenWriter.cpp.orig 2004-08-21 15:56:41.965475856 +0200 +++ abiword-plugins/wp/impexp/OpenWriter/xp/ie_imp_OpenWriter.cpp 2004-08-21 16:16:54.183190752 +0200 @@ -22,6 +22,7 @@ #include #include +#include #include "ie_impexp_OpenWriter.h" #include "ie_impGraphic.h" @@ -29,6 +30,7 @@ #include "fg_GraphicRaster.h" #include "pd_Document.h" +#include "pd_Style.h" // abiword stuff #include "ut_xml.h" @@ -54,18 +56,18 @@ { public: - OO_Style (const XML_Char ** props) + OO_Style (const XML_Char ** props, const PD_Style * pParentStyle) : m_bColBreakBefore (false), m_bPageBreakBefore (false) { - parse (props); + parse (props, pParentStyle); } - OO_Style (const OO_Style * other, const XML_Char ** props) + OO_Style (const OO_Style * other, const XML_Char ** props, PD_Style * pParentStyle) : m_bColBreakBefore (false), m_bPageBreakBefore (false) { if (other) *this = *other; - parse (props); + parse (props, pParentStyle); } ~OO_Style () @@ -93,11 +95,11 @@ private: - void parse (const XML_Char ** props) + void parse (const XML_Char ** props, const PD_Style * pParentStyle) { const XML_Char** p = props; const XML_Char * val = NULL; - + val = UT_getAttribute ("fo:text-align", props); if (val) if (!UT_strcmp(val, "end")) @@ -130,12 +132,21 @@ m_bgcolor = UT_String_sprintf ("bgcolor: %s;", val); val = UT_getAttribute("style:font-name", props); - if(val) - m_fontName = UT_String_sprintf ("font-face: %s;", val); - + if(val) + m_fontName = UT_String_sprintf ("font-family: %s;", val); + val = UT_getAttribute("fo:font-size", props); - if(val) - m_fontSize = UT_String_sprintf ("font-size: %s;", val); + if(val) { + if ((val[strlen(val)-1] == '%') && pParentStyle) { + // calculate font-size based on parent's + const XML_Char * parentFontSize = NULL; + pParentStyle->getProperty("font-size", parentFontSize); + double fontSize = atoi(parentFontSize) * atoi(val) / 100.0; + m_fontSize = UT_String_sprintf ("font-size: %gpt;", rint(fontSize)); + } + else + m_fontSize = UT_String_sprintf ("font-size: %s;", val); + } if (UT_getAttribute("fo:language", props) && UT_getAttribute("fo:country", props)) m_lang = UT_String_sprintf ("lang: %s-%s;", UT_getAttribute("fo:language", props), @@ -391,7 +402,7 @@ if (!name.size() || !props) return; - OO_Style * style = new OO_Style (props); + OO_Style * style = new OO_Style (props, NULL); m_styleBucket.insert (name.utf8_str(), style); } @@ -452,8 +463,6 @@ return err; if ( UT_OK != (err = _handleStylesStream ())) return err; - if ( UT_OK != (err = _handleStylesStream ())) - return err; if ( UT_OK != (err = _handleContentStream ())) return err; @@ -735,8 +744,10 @@ } DELETEP(m_ooStyle); } - else if (!strcmp (name, "style:properties")) - m_ooStyle = new OO_Style (atts); + else if (!strcmp (name, "style:properties")) { + getDocument()->getStyle (m_parent.utf8_str(), &m_pParentStyle); + m_ooStyle = new OO_Style (atts, m_pParentStyle); + } } virtual void endElement (const XML_Char * name) @@ -774,9 +785,8 @@ m_name.clear (); m_parent.clear (); m_next.clear (); + DELETEP(m_ooStyle); } - - DELETEP(m_ooStyle); } virtual void charData (const XML_Char * buffer, int length) @@ -790,6 +800,7 @@ UT_UTF8String m_next; enum { CHARACTER, PARAGRAPH } m_type; OO_Style *m_ooStyle; + PD_Style *m_pParentStyle; }; /*!