Hiyas all-
I'm new around here *waves*; attached find a (hopefully acceptable?)
patch which improves AbiWord's LaTeX export in the following ways:
* add support for strikeout style
* improves underline support
* adds color and bgcolor support

Is this the right place to post patches?
If so, could someone look it over and commit (if acceptable);
if not, where should I post it?

-- 
  -nils (aka pookie)
Index: abi/src/wp/impexp/xp/ie_exp_LaTeX.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_LaTeX.cpp,v
retrieving revision 1.28
diff -u -r1.28 ie_exp_LaTeX.cpp
--- abi/src/wp/impexp/xp/ie_exp_LaTeX.cpp       2001/06/26 12:20:25     1.28
+++ abi/src/wp/impexp/xp/ie_exp_LaTeX.cpp       2001/07/06 07:49:34
@@ -443,10 +443,16 @@
 
 void s_LaTeX_Listener::_convertColor(char* szDest, const char* pszColor)
 {
-       /*
-         TODO I've no clue about the colors in LaTeX
-       */
-       strcpy(szDest, pszColor);
+       char colors[3][3];
+       for (int i=0;i<3;++i)
+       {
+               strncpy (colors[i],&pszColor[2*i],2);
+               colors[i][2]=0;
+       }
+       sprintf (szDest, "%.3f,%.3f,%.3f",
+                                       strtol (&colors[0][0],NULL,16)/255.,
+                                       strtol (&colors[1][0],NULL,16)/255.,
+                                       strtol (&colors[2][0],NULL,16)/255.);
 }
 
 void s_LaTeX_Listener::_convertFontSize(char* szDest, const char* pszFontSize)
@@ -538,11 +544,14 @@
                        UT_ASSERT(p || !pszDecor);
                        XML_Char*       q = strtok(p, " ");
 
+                       // See the ulem.sty documentation (available at www.ctan.org)
+                       // if you wish to include other kinds of underlines, such as
+                       // double underlines or wavy underlines
                        while (q)
                        {
                          if (0 == UT_strcmp(q, "underline")) // TODO: 
\def\undertext#1{$\underline{\vphantom{y}\smash{\hbox{#1}}}$}
                                {
-                                       m_pie->write("\\underline{");
+                                       m_pie->write("\\uline{");
                                }
 
                                if (0 == UT_strcmp(q, "overline"))
@@ -552,7 +561,7 @@
 
                                if (0 == UT_strcmp(q, "line-through"))
                                {
-                                       m_pie->write("");       // TODO
+                                       m_pie->write("\\sout{");
                                }
 
                                q = strtok(NULL, " ");
@@ -573,10 +582,27 @@
                        }
                }
                
-               if (pAP->getProperty("color", szValue))
-               {
-                       UT_DEBUGMSG (("Latex export: TODO: 'color' property\n"));
+               const XML_Char* pszColor = NULL;
+               pAP->getProperty("color", pszColor);
+               if (pszColor)
+               {
+                       char szColor[18];
+                       _convertColor(szColor,(char*)pszColor);
+                       m_pie->write("\\textcolor[rgb]{");
+                       m_pie->write(szColor);
+                       m_pie->write("}{");
                }
+               
+               const XML_Char* pszBgColor = NULL;
+               pAP->getProperty("bgcolor", pszBgColor);
+               if (pszBgColor)
+               {
+                       char szColor[18];
+                       _convertColor(szColor,(char*)pszBgColor);
+                       m_pie->write("\\colorbox[rgb]{");
+                       m_pie->write(szColor);
+                       m_pie->write("}{");
+               }
 
                if (pAP->getProperty("font-size", szValue))
                {
@@ -611,8 +637,17 @@
        {
                const XML_Char * szValue;
                
-               if (// (pAP->getProperty("color", szValue)) ||    // TODO
-                   (pAP->getProperty("font-size", szValue))
+               if (pAP->getProperty("color", szValue))
+               {
+                       m_pie->write("}");
+               }
+
+               if (pAP->getProperty("bgcolor", szValue))
+               {
+                       m_pie->write("}");
+               }
+
+               if ((pAP->getProperty("font-size", szValue))
 //                 || (pAP->getProperty("font-family", szValue))  // TODO
                        )
                {
@@ -651,7 +686,7 @@
                        {
                                if (0 == UT_strcmp(q, "line-through"))
                                {
-                                       m_pie->write("");       // TODO
+                                       m_pie->write("}");
                                }
 
                                q = strtok(NULL, " ");
@@ -906,6 +941,8 @@
        m_pie->write("\\usepackage{calc}\n");
        m_pie->write("\\usepackage{setspace}\n");
        m_pie->write("\\usepackage{multicol}\t% TODO: I don't need this package if the 
document is a single column one.\n");
+       m_pie->write("\\usepackage[normalem]{ulem}\t% TODO: Package is only needed if 
+you have underline/strikeout.\n");
+       m_pie->write("\\usepackage{color}\t% TODO: Package is only needed if you have 
+color.\n");
        {
            const char* misc = XAP_EncodingManager::get_instance()->getTexPrologue();
            if (misc)
@@ -2168,7 +2205,3 @@
        return(0);
        }
 #undef printf
-
-
-
-

Reply via email to