]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlatexaccent.C
Add support for compilers which do not have cname headers
[lyx.git] / src / insets / insetlatexaccent.C
index c715a0cfcaa11cd2eb0f2f330933dadd2ef0e0fc..31c415afa8a587ca46684e76aad519bd79017b8a 100644 (file)
@@ -3,10 +3,10 @@
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1998 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ======================================================*/
 
 #include <config.h>
 
 #endif
 
 #include "insetlatexaccent.h"
-#include "error.h"
+#include "debug.h"
 #include "lyxrc.h"
 #include "lyxdraw.h"
+#include "support/lstrings.h"
 
 extern LyXRC * lyxrc;
 
-//     $Id: insetlatexaccent.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $  
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: insetlatexaccent.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $";
-#endif /* lint */
-
 /* LatexAccent. Proper handling of accented characters */
 /* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */
 /* Later modified by Lars G. Bjonnes, larsbj@ifi.uio.no */
@@ -48,7 +43,7 @@ InsetLatexAccent::InsetLatexAccent(InsetLatexAccent const & other)
 {}
 
 
-InsetLatexAccent::InsetLatexAccent(LString const & string)
+InsetLatexAccent::InsetLatexAccent(string const & string)
        : contents(string)
 {
        checkContents();
@@ -69,17 +64,16 @@ void InsetLatexAccent::checkContents()
 
        // REMOVE IN 0.13
        // Dirty Hack for backward compability. remove in 0.13 (Lgb)
-       contents.strip();
-       contents.frontStrip();
-       if (!contents.contains("{") && !contents.contains("}")) {
+       contents = frontStrip(strip(contents));
+       if (!contains(contents, "{") && !contains(contents, "}")) {
                if (contents.length() == 2) {
-                       LString tmp;
+                       string tmp;
                        tmp += contents[0];
                        tmp += contents[1];
                        tmp += "{}";
                        contents = tmp;
                } else if (contents.length() == 3) {
-                       LString tmp;
+                       string tmp;
                        tmp += contents[0];
                        tmp += contents[1];
                        tmp += '{';
@@ -87,7 +81,7 @@ void InsetLatexAccent::checkContents()
                        tmp += '}';
                        contents = tmp;
                } else if (contents.length()==4 && contents[2] == ' ') {
-                       LString tmp;
+                       string tmp;
                        tmp += contents[0];
                        tmp += contents[1];
                        tmp += '{';
@@ -96,7 +90,7 @@ void InsetLatexAccent::checkContents()
                        contents = tmp;
                } else if  (contents.length()==4 && contents[2] == '\\'
                            && (contents[3]== 'i' || contents[3]== 'j')) {
-                       LString tmp;
+                       string tmp;
                        tmp += contents[0];
                        tmp += contents[1];
                        tmp += '{';
@@ -108,7 +102,7 @@ void InsetLatexAccent::checkContents()
        }
         if (contents[0] != '\\') return; // demand that first char is a '\\'
 
-       lyxerr.debug("Decode: " + contents);
+       lyxerr.debug() << "Decode: " << contents << endl;
 
         remdot = false; plusasc = false; plusdesc = false;
 
@@ -219,15 +213,16 @@ void InsetLatexAccent::checkContents()
                case LSLASH:     ic = 'L'; break;
                default:
                        // if this happens something is really wrong
-                       lyxerr.print("InsetLaTexAccent: weird error.");
+                       lyxerr << "InsetLaTexAccent: weird error." << endl;
                        break;
                }
                //ic = (modtype == DOT_LESS_J ? 'j' : 'i');
-               lyxerr.debug("Contents: [" + contents + "], ic: " + ic 
-                            + ", top: " + long(plusasc) 
-                            + ", bot: " + long(plusdesc) 
-                            + ", dot: " + long(remdot) 
-                            + ", mod: " + long(modtype));
+               lyxerr.debug() << "Contents: [" << contents << "]"
+                              << ", ic: " << ic 
+                              << ", top: " << plusasc 
+                              << ", bot: " << plusdesc 
+                              << ", dot: " << remdot 
+                              << ", mod: " << modtype << endl;
        // Special case for space
        } else if (contents[3] == '}') {
                ic = ' ';
@@ -246,11 +241,11 @@ void InsetLatexAccent::checkContents()
                                return;
                } else if ( (ic=='i'|| ic=='j') && contents[4]=='}') {
                    // Do a rewrite: \<foo>{i} --> \<foo>{\i}
-                   LString temp=contents;
-                   temp.substring(0,2);
+                   string temp=contents;
+                   temp.erase(3, string::npos);
                    temp+='\\';
                        temp+=char(ic);
-                   for(int j=4;j<contents.length();j++)
+                   for(string::size_type j = 4; j < contents.length(); ++j)
                                temp+=contents[j];
                    contents=temp;
                    i++;
@@ -261,11 +256,12 @@ void InsetLatexAccent::checkContents()
                if (contents[++i] != '}' && contents[++i]) return;
                                           
                // fine, the char is properly decoded now (hopefully)
-               lyxerr.debug("Contents: [" + contents + "], ic: " + ic
-                            + ", top: " + long(plusasc) 
-                            + ", bot: " + long(plusdesc) 
-                            + ", dot: " + long(remdot) 
-                            + ", mod: " + long(modtype));
+               lyxerr.debug() << "Contents: [" << contents << "]"
+                              << ", ic: " << ic
+                              << ", top: " << plusasc 
+                              << ", bot: " << plusdesc 
+                              << ", dot: " << remdot
+                              << ", mod: " << modtype << endl;
        }
         candisp = true;
 }
@@ -399,7 +395,7 @@ void InsetLatexAccent::Draw(LyXFont font,
                        int tmpvar = baseline - font.ascent('i');
                        float tmpx = 0;
                        if (font.shape() == LyXFont::ITALIC_SHAPE) tmpx += (8*hg)/10; // italic
-                       lyxerr.debug("Removing dot.", Error::ANY);
+                       lyxerr.debug() << "Removing dot." << endl;
                        // remove the dot first
                        scr.fillRectangle(gc_clear, int(x + tmpx),
                                          tmpvar, wid,
@@ -615,21 +611,21 @@ int InsetLatexAccent::Latex(FILE *file, signed char /*fragile*/)
 }
 
 
-int InsetLatexAccent::Latex(LString &file, signed char /*fragile*/)
+int InsetLatexAccent::Latex(string &file, signed char /*fragile*/)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatexAccent::Linuxdoc(LString &file)
+int InsetLatexAccent::Linuxdoc(string &file)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatexAccent::DocBook(LString &file)
+int InsetLatexAccent::DocBook(string &file)
 {
        file += contents;
        return 0;
@@ -669,3 +665,8 @@ bool InsetLatexAccent::IsEqual(Inset* other)
        }
        return false;
 }
+
+ostream & operator<<(ostream & o, InsetLatexAccent::ACCENT_TYPES at)
+{
+       return o << int(at);
+}