]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetspecialchar.C
pos=string::npos for regex not found, use handcoded transform in lstring.C, fix the...
[lyx.git] / src / insets / insetspecialchar.C
index 2e61e5f20b90d8ec2b852d9e3c1eb72a3bbefbd4..f1074c604f4b0d5276ae906f46f90adb8e28f296 100644 (file)
@@ -5,7 +5,7 @@
  *      
  *         Copyright 1997 Asger Alstrup
  *
- * ======================================================*/
+ * ====================================================== */
 
 #include <config.h>
 
 #include "debug.h"
 #include "LaTeXFeatures.h"
 
-InsetSpecialChar::InsetSpecialChar()
-{
-}
-
-
 InsetSpecialChar::InsetSpecialChar(Kind k)
        : kind(k)
-{
-}
-
-
-InsetSpecialChar::~InsetSpecialChar()
-{
-}
+{}
 
 
-int InsetSpecialChar::Ascent(LyXFont const&font) const
+int InsetSpecialChar::Ascent(LyXFont const & font) const
 {
        return font.maxAscent();
 }
 
 
-int InsetSpecialChar::Descent(LyXFont const&font) const
+int InsetSpecialChar::Descent(LyXFont const & font) const
 {
        return font.maxDescent();
 }
 
 
-int InsetSpecialChar::Width(LyXFont const&font) const
+int InsetSpecialChar::Width(LyXFont const & font) const
 {
        LyXFont f = font;
        switch (kind) {
@@ -73,8 +62,8 @@ int InsetSpecialChar::Width(LyXFont const&font) const
 }
 
 
-void InsetSpecialChar::Draw(LyXFont font, LyXScreen &scr,
-                           int baseline, float &x)
+void InsetSpecialChar::Draw(LyXFont font, LyXScreen & scr,
+                           int baseline, float & x)
 {
        switch (kind) {
        case HYPHENATION:
@@ -117,7 +106,7 @@ void InsetSpecialChar::Draw(LyXFont font, LyXScreen &scr,
 
 
 // In lyxf3 this will be just LaTeX
-void InsetSpecialChar::Write(FILE *file)
+void InsetSpecialChar::Write(ostream & os)
 {
        string command;
        switch (kind) {
@@ -126,40 +115,40 @@ void InsetSpecialChar::Write(FILE *file)
        case LDOTS:             command = "\\ldots{}";  break;
        case MENU_SEPARATOR:    command = "\\menuseparator"; break;
        }
-       fprintf(file, "\\SpecialChar %s\n", command.c_str());
+       os << "\\SpecialChar " << command << "\n";
 }
 
 
 // This function will not be necessary when lyx3
-void InsetSpecialChar::Read(LyXLex &lex)
+void InsetSpecialChar::Read(LyXLex & lex)
 {    
        lex.nextToken();
        string command = lex.GetString();
 
-       if (command=="\\-")
+       if (command == "\\-")
                kind = HYPHENATION;
-       else if (command=="\\@.")
+       else if (command == "\\@.")
                kind = END_OF_SENTENCE;
-       else if (command=="\\ldots{}")
+       else if (command == "\\ldots{}")
                kind = LDOTS;
-       else if (command=="\\menuseparator")
+       else if (command == "\\menuseparator")
                kind = MENU_SEPARATOR;
        else
                lex.printError("InsetSpecialChar: Unknown kind: `$$Token'");
 }
 
 
-int InsetSpecialChar::Latex(FILE *file, signed char /*fragile*/)
+int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/)
 {
        string command;
        signed char dummy = 0;
        Latex(command, dummy);
-       fprintf(file, "%s", command.c_str());
+       os << command;
        return 0;
 }
 
 
-int InsetSpecialChar::Latex(string &file, signed char /*fragile*/)
+int InsetSpecialChar::Latex(string & file, signed char /*fragile*/)
 {
        switch (kind) {
        case HYPHENATION:       file += "\\-";  break;
@@ -171,7 +160,7 @@ int InsetSpecialChar::Latex(string &file, signed char /*fragile*/)
 }
 
 
-int InsetSpecialChar::Linuxdoc(string &file)
+int InsetSpecialChar::Linuxdoc(string & file)
 {
        switch (kind) {
        case HYPHENATION:       file += "";     break;
@@ -183,7 +172,7 @@ int InsetSpecialChar::Linuxdoc(string &file)
 }
 
 
-int InsetSpecialChar::DocBook(string &file)
+int InsetSpecialChar::DocBook(string & file)
 {
        switch (kind) {
        case HYPHENATION:       file += "";     break;
@@ -195,14 +184,13 @@ int InsetSpecialChar::DocBook(string &file)
 }
 
 
-Inset* InsetSpecialChar::Clone()
+Inset * InsetSpecialChar::Clone() const
 {
-       InsetSpecialChar *result = new InsetSpecialChar(kind);
-       return result;
+       return new InsetSpecialChar(kind);
 }
 
 
-void InsetSpecialChar::Validate(LaTeXFeatures& features) const
+void InsetSpecialChar::Validate(LaTeXFeatures & features) const
 {
        if (kind == MENU_SEPARATOR) {
                features.lyxarrow = true;