]> git.lyx.org Git - features.git/commitdiff
change to use only ostream to write latex from insets
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 2 Mar 2000 02:19:43 +0000 (02:19 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 2 Mar 2000 02:19:43 +0000 (02:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@581 a592a061-630c-0410-9148-cb99ea01b6c8

43 files changed:
ChangeLog
acinclude.m4
config/lyxinclude.m4
src/insets/figinset.C
src/insets/figinset.h
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/inseturl.C
src/insets/inseturl.h
src/insets/lyxinset.h
src/lyxlookup.C
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/mathed/math_utils.C
src/paragraph.C
src/support/filetools.C
src/text.C

index 6475fc4d9d26eae341761c6ae39b7cf52cb8f542..f1b17ae886bf1c7974381da667d01388c96d1409 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-03-02  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/mathed/math_utils.C (MathedLookupBOP): using only res->id ==
+       id in the check of the result from lower_bound is not enough since
+       lower_bound can return last too, and then res->id will not be a
+       valid construct.
+
+       *  all insets and some code that use them: I have conditionalized
+       removed the Latex(string & out, ...) this means that only the
+       Latex(ostream &, ...) will be used. This is a work in progress to
+       move towards using streams for all output of files. 
+
+       * src/text.C (GetColumnNearX): initialize LyXParagraph::size_type
+       c to 0.
+
 2000-03-02  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/mathed/math_utils.C (MathedLookupBOP): fix the search
index f055262b95afaca168f962c45dbe7becaa3b7f32..7c317dbd2385bbcd33c7564b024d0040cd1e9f8e 100644 (file)
@@ -183,7 +183,7 @@ dnl Check the version of g++
     CXXFLAGS="$ac_save_CXXFLAGS"
   elif test $ac_cv_prog_cxx_g = yes; then
     case $gxx_version in
-      2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
+      2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
       2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       2.96*)   CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
@@ -194,9 +194,9 @@ dnl Check the version of g++
   fi
   if test x$with_warnings = xyes ; then
     case $gxx_version in
-       2.95.*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
-       2.96*)  CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
-       *)      CXXFLAGS="$CXXFLAGS -ansi -Wall -W -Wno-return-type";;
+       2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+       2.96*)  CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+       *)      CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
     esac
     if test $lyx_devel_version = yes ; then
        case $gxx_version in
index bf009dc7c209170f0dd2fd119851b77a381069ed..a430a0933a028380aea50ee88834ebdd94536944 100644 (file)
@@ -183,7 +183,7 @@ dnl Check the version of g++
     CXXFLAGS="$ac_save_CXXFLAGS"
   elif test $ac_cv_prog_cxx_g = yes; then
     case $gxx_version in
-      2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";;
+      2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
       2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       2.96*)   CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
       *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
@@ -194,9 +194,9 @@ dnl Check the version of g++
   fi
   if test x$with_warnings = xyes ; then
     case $gxx_version in
-       2.95.*) CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
-       2.96*)  CXXFLAGS="$CXXFLAGS -Wall -W -Wconversion";;
-       *)      CXXFLAGS="$CXXFLAGS -ansi -Wall -W -Wno-return-type";;
+       2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+       2.96*)  CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion";;
+       *)      CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
     esac
     if test $lyx_devel_version = yes ; then
        case $gxx_version in
index 1c3939b8c93b36c39284d5c85dc23e54efd555f9..6bc9176219f5299b3a7e14c18492db94ee756e63 100644 (file)
@@ -1202,12 +1202,14 @@ int InsetFig::Latex(ostream & os, signed char /* fragile*/ ) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
 {
        Regenerate();
        file += cmd + ' ';
        return 0;
 }
+#endif
 
 
 int InsetFig::Linuxdoc(string &/*file*/) const
index 1ee86e042ac3c23946b9419725a1395b35985ecd..83234badc5c1e6c5eccd6829da9d8c2905517ba0 100644 (file)
@@ -39,8 +39,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index dd34a47a2222afbf9f26610a10ac967ec5aa20d6..61f71bcb4ad48df8e842e6e0ffeb2ec96258e5a1 100644 (file)
@@ -313,14 +313,52 @@ string InsetBibtex::getScreenLabel() const
 
 int InsetBibtex::Latex(ostream & os, signed char /*fragile*/) const
 {
+#ifdef USE_OSTREAM_ONLY
+       // this looks like an horrible hack and it is :) The problem
+       // is that owner is not initialized correctly when the bib
+       // inset is cut and pasted. Such hacks will not be needed
+       // later (JMarc)
+       if (!owner) {
+               owner = current_view->buffer();
+       }
+       // If we generate in a temp dir, we might need to give an
+       // absolute path there. This is a bit complicated since we can
+       // have a comma-separated list of bibliographies
+       string adb, db_out;
+       string db_in = getContents();
+       db_in = split(db_in, adb, ',');
+       while(!adb.empty()) {
+               if (!owner->niceFile &&
+                   IsFileReadable(MakeAbsPath(adb, owner->filepath)+".bib")) 
+                       adb = MakeAbsPath(adb, owner->filepath);
+               db_out += adb;
+               db_out += ',';
+               db_in= split(db_in, adb,',');
+       }
+       db_out = strip(db_out, ',');
+       // Idem, but simpler
+       string style;
+       if (!owner->niceFile 
+           && IsFileReadable(MakeAbsPath(getOptions(), owner->filepath)
+                             + ".bst")) 
+               style = MakeAbsPath(getOptions(), owner->filepath);
+       else
+               style = getOptions();
+
+       os << "\\bibliographystyle{" << style << "}\n"
+          << "\\bibliography{" << db_out << "}\n";
+       return 2;
+#else
        string bib;
        signed char dummy = 0;
        int result = Latex(bib, dummy);
        os << bib;
        return result;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
 {
        // this looks like an horrible hack and it is :) The problem
@@ -362,7 +400,7 @@ int InsetBibtex::Latex(string & file, signed char /*fragile*/) const
        file += "}\n";
        return 2;
 }
-
+#endif
 
 // This method returns a comma separated list of Bibtex entries
 string InsetBibtex::getKeys(char delim)
index 3b862fb3e98101d3b073a448f8eff4192497e614..32063d1b86de39cb7be5bc5789406c788d824238 100644 (file)
@@ -128,8 +128,10 @@ public:
        void Edit(BufferView *, int x, int y, unsigned int button);
        /// 
        int Latex(ostream &, signed char) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        string getKeys(char delim);
        ///
index 61d516961a976674cba60fa71cec0ce93a60fd93..9c7c8b1bda3dbf215a5e0b492ce437be7ff5f685 100644 (file)
@@ -251,11 +251,13 @@ int InsetCommand::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetCommand::Latex(string & file, signed char /*fragile*/) const
 {
        file += getCommand();
        return 0;
 }
+#endif
 
 
 int InsetCommand::Linuxdoc(string &/*file*/) const
index c784b195441d99afe9243f36b0c0e2fcef0c6b30..bc3cb17978710e5058d6c3193a18f452faac2cc2 100644 (file)
@@ -48,8 +48,10 @@ public:
        void Read(LyXLex & lex);
        /// 
        virtual int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        virtual int Latex(string & file, signed char fragile) const;
+#endif
        ///
        virtual int Linuxdoc(string & file) const;
        ///
index d41ad691db05da746c36cfa1f5033b36db4cb18c..93fbda4a4db18786a8693c9166508598cff82e7e 100644 (file)
@@ -107,10 +107,12 @@ int InsetError::Latex(ostream &, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetError::Latex(string &, signed char /*fragile*/) const
 {
        return 0;
 }
+#endif
 
 
 int InsetError::Linuxdoc(string &) const
index 4fe255658633ca6d7ee0763695e8817cc6883941..86f7c712f94c824109af727be2aa397989b3f7e2 100644 (file)
@@ -48,8 +48,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 1d7e0306df1b3786a8b9baa2bbc143623063ab99..dcbfc71a35766f87c6d776557733e2efeb955e3d 100644 (file)
@@ -225,10 +225,12 @@ int InsetGraphics::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetGraphics::Latex(string & /*file*/, signed char /*fragile*/) const
 {
        return 0;
 }
+#endif
 
 
 int InsetGraphics::Linuxdoc(string & /*file*/) const
index 27de01f9afebf1bcd6640d75ba46bf9a446cd171..f54d1f29adc2a3457087ba47a9489061ca91bfe6 100644 (file)
@@ -46,8 +46,10 @@ public:
         fragile commands by adding a \protect before.
         */
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & /*file*/) const;
        ///
index b9fdd55e03e7e8d46e0f9847ab9c354194f9f839..1007ea6eef87a39222fca9184ca376cfbad4e356 100644 (file)
@@ -317,24 +317,91 @@ bool InsetInclude::loadIfNeeded() const
 
 int InsetInclude::Latex(ostream & os, signed char /*fragile*/) const
 {
+#ifdef USE_OSTREAM_ONLY
+       // Do nothing if no file name has been specified
+       if (contents.empty())
+               return 0;
+    
+       // Use += to force a copy of contents (JMarc)
+       // How does that force anything? (Lgb)
+       string incfile(contents);
+
+       if (loadIfNeeded()) {
+               Buffer * tmp = bufferlist.getBuffer(getFileName());
+
+               if (tmp->params.textclass != master->params.textclass) {
+                       lyxerr << "ERROR: Cannot handle include file `"
+                              << MakeDisplayPath(getFileName())
+                              << "' which has textclass `"
+                              << textclasslist.NameOfClass(tmp->params.textclass)
+                              << "' instead of `"
+                              << textclasslist.NameOfClass(master->params.textclass)
+                              << "'." << endl;
+                       return 0;
+               }
+               
+               // write it to a file (so far the complete file)
+               string writefile = ChangeExtension(getFileName(), ".tex", false);
+               if (!master->tmppath.empty()
+                   && !master->niceFile) {
+                       incfile = subst(incfile, '/','@');
+#ifdef __EMX__
+                       incfile = subst(incfile, ':', '$');
+#endif
+                       writefile = AddName(master->tmppath, incfile);
+               } else
+                       writefile = getFileName();
+               writefile = ChangeExtension(writefile, ".tex", false);
+               lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
+               lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
+               
+               tmp->markDepClean(master->tmppath);
+               
+               tmp->makeLaTeXFile(writefile,
+                                  OnlyPath(getMasterFilename()), 
+                                  master->niceFile, true);
+       } 
+
+       if (isVerb()) {
+               os << '\\' << command << '{' << incfile << '}';
+       } 
+       else if (isInput()) {
+               // \input wants file with extension (default is .tex)
+               if (!IsLyXFilename(getFileName())) {
+                       os << '\\' << command << '{' << incfile << '}';
+               } else {
+                       os << '\\' << command << '{'
+                          << ChangeExtension(incfile, ".tex", false)
+                          <<  '}';
+               }
+       } else {
+               // \include don't want extension and demands that the
+               // file really have .tex
+               os << '\\' << command << '{'
+                  << ChangeExtension(incfile, string(), false)
+                  << '}';
+       }
+
+       return 0;
+#else
        string include_file;
        signed char dummy = 0;
        Latex(include_file, dummy);
        os << include_file;
        return 0;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetInclude::Latex(string & file, signed char /*fragile*/) const
 {
-       string writefile, incfile;
-
        // Do nothing if no file name has been specified
        if (contents.empty())
                return 0;
     
        // Use += to force a copy of contents (JMarc)
-       incfile += contents;
+       string incfile += contents;
 
        if (loadIfNeeded()) {
                Buffer * tmp = bufferlist.getBuffer(getFileName());
@@ -351,7 +418,8 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const
                }
                
                // write it to a file (so far the complete file)
-               writefile = ChangeExtension(getFileName(), ".tex", false);
+               string writefile =
+                       ChangeExtension(getFileName(), ".tex", false);
                if (!master->tmppath.empty()
                    && !master->niceFile) {
                        incfile = subst(incfile, '/','@');
@@ -400,6 +468,7 @@ int InsetInclude::Latex(string & file, signed char /*fragile*/) const
 
        return 0;
 }
+#endif
 
 
 void InsetInclude::Validate(LaTeXFeatures & features) const
index 0cd817b2f2782d4b53d3020a9ac609cb0a7fd743..7ea9085fa0eeca45bc7792bd87d37e7323d4d16d 100644 (file)
@@ -59,9 +59,10 @@ public:
        void Read(LyXLex &);
        /// 
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
-       
+#endif
        ///
        void Validate(LaTeXFeatures &) const;
        
index 848285ee59e78d1772450a13eae5de529434f4f7..9499ec0de25fa74705dd9a005cce3008c7576fb6 100644 (file)
@@ -132,10 +132,12 @@ int InsetInfo::Latex(ostream &, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetInfo::Latex(string &, signed char /*fragile*/) const
 {
        return 0;
 }
+#endif
 
 
 int InsetInfo::Linuxdoc(string &) const
index 20ffaf207cbea591c91e979c1ce428c89b53c874..5fa617c66b68b5fb3a5f825fec1830972b1ae5b2 100644 (file)
@@ -50,8 +50,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 9e5143df54f8e7d4046b4f3cafe507a7a008eef7..697a524079e1da3088df8820d33eb4218134d388 100644 (file)
@@ -50,11 +50,13 @@ int InsetLabel::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetLabel::Latex(string & file, signed char /*fragile*/) const
 {
        file += escape(getCommand());
        return 0;
 }
+#endif
 
 
 int InsetLabel::Linuxdoc(string & file) const
index d4366befd68144213d013b3ce8663a7f7954ba5f..9c95af71ef2a578d9b1bdc66abad6119754367d4 100644 (file)
@@ -40,8 +40,10 @@ public:
        unsigned char Editable() const { return 0; }
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 671c97d38b262a1614b2dbf61202ffd32d8074fb..0adb04841d2622fb7f65fbca782705da41df87bf 100644 (file)
@@ -752,11 +752,13 @@ int InsetLatexAccent::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetLatexAccent::Latex(string & file, signed char /*fragile*/) const
 {
        file += contents;
        return 0;
 }
+#endif
 
 
 int InsetLatexAccent::Linuxdoc(string & file) const
index 53fef7fb1ecadde47da231a1f8a133908266de34..1da3e79482f77f1df5e7d7de1adfb65497e4eda9 100644 (file)
@@ -54,8 +54,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 0fd046ddabfbb9911a184b2281c8794ea12b0509..fb06667f8ff868fe177b33fa763b7f8ddd0e7552 100644 (file)
@@ -51,6 +51,7 @@ int InsetParent::Latex(ostream & os, signed char fragile) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 // LaTeX must just ignore this command
 int InsetParent::Latex(string & file, signed char fragile) const
 {
@@ -58,3 +59,4 @@ int InsetParent::Latex(string & file, signed char fragile) const
        InsetCommand::Latex(file, fragile);
        return 0;
 }
+#endif
index 2e863c1deab46702289576f0dbc701b6a8378ba9..cc0ecb319d9cd313941dcf337273a12721ef6e9d 100644 (file)
@@ -33,8 +33,10 @@ public:
         InsetParent(string const & fn, Buffer * owner = 0);
        /// 
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
         ///
         Inset * Clone() const { return new InsetParent(getContents()); }
        ///
index 0e731c4c960c1a83be630816923682c859213d23..3e044d20c5ce6189a2cc1c0b25eeee50711aee1d 100644 (file)
@@ -226,13 +226,52 @@ void InsetQuotes::Read(LyXLex & lex)
 
 int InsetQuotes::Latex(ostream & os, signed char /*fragile*/) const
 {
+#ifdef USE_OSTREAM_ONLY
+       string doclang = 
+               current_view->buffer()->GetLanguage();
+       int quoteind = quote_index[side][language];
+       string qstr;
+       
+       if (lyxrc->fontenc == "T1") {
+               qstr = latex_quote_t1[times][quoteind];
+       }
+       else if (doclang == "default") {
+               qstr = latex_quote_ot1[times][quoteind];
+       } 
+       else if (language == InsetQuotes::FrenchQ 
+                && times == InsetQuotes::DoubleQ
+                && doclang == "frenchb") {
+               if (side == InsetQuotes::LeftQ) 
+                       qstr = "\\og{}";
+               else 
+                       qstr = " \\fg{}";
+       } 
+       else 
+               qstr = latex_quote_babel[times][quoteind];
+
+       // protect against !` and ?` ligatures.
+       // Is it very bad of us to always protect against those ligatures?
+#if 0
+       if ((suffixIs(file, '?') || suffixIs(file, '!'))
+           && qstr[0] == '`')
+               qstr = "{}" + qstr;
+#else
+       // Always guard against unfortunate ligatures (!` ?`)
+       qstr.insert(0, "{}");
+#endif
+
+       os << qstr;
+       return 0;
+#else
        string quote;
        int res = Latex(quote, 0);
        os << quote;
        return res;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
 {
        string doclang = 
@@ -265,6 +304,7 @@ int InsetQuotes::Latex(string & file, signed char /*fragile*/) const
        file += qstr;
        return 0;
 }
+#endif
 
 
 int InsetQuotes::Linuxdoc(string & file) const
index 69fbc5605d06a0bc370f4a4c238a3123e8986a3b..cd554cf2803bccdefeaa8bb07bf70de703dfeb59 100644 (file)
@@ -86,8 +86,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 79dd93287286e8ba33968288c41b360511dfa465..bd0fa93757b74553131b9556ce25789e4eb18bb5 100644 (file)
@@ -81,6 +81,7 @@ int InsetRef::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetRef::Latex(string & file, signed char /*fragile*/) const
 {
        if(getOptions().empty())
@@ -93,6 +94,7 @@ int InsetRef::Latex(string & file, signed char /*fragile*/) const
        }
        return 0;
 }
+#endif
 
 
 int InsetRef::Linuxdoc(string & file) const
index 3644753e2316efea6cbedba294ba9fe865c78a14..4c897c93f7a3de1907911d67e3dd62f2ad78620e 100644 (file)
@@ -62,8 +62,10 @@ public:
         void gotoLabel();
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 3c4193b08fb5283f72d5d97f3d5349023baca844..2db0639952729161b8e0c490c524d9d2fef18f71 100644 (file)
@@ -189,14 +189,26 @@ void InsetSpecialChar::Read(LyXLex & lex)
 
 int InsetSpecialChar::Latex(ostream & os, signed char /*fragile*/) const
 {
+#ifdef USE_OSTREAM_ONLY
+       switch (kind) {
+       case HYPHENATION:         os << "\\-";  break;
+       case END_OF_SENTENCE:     os << "\\@."; break;
+       case LDOTS:               os << "\\ldots{}";    break;
+       case MENU_SEPARATOR:      os << "\\lyxarrow{}"; break;
+       case PROTECTED_SEPARATOR: os << "~";          break;
+       }
+       return 0;
+#else
        string command;
        signed char dummy = 0;
        Latex(command, dummy);
        os << command;
        return 0;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
 {
        switch (kind) {
@@ -208,6 +220,7 @@ int InsetSpecialChar::Latex(string & file, signed char /*fragile*/) const
        }
        return 0;
 }
+#endif
 
 
 int InsetSpecialChar::Linuxdoc(string & file) const
index 80691341865cdfe3874a9c4776dd432118ff3e85..410b66ed16d7478d05d35dbbef6046bc847acbfa 100644 (file)
@@ -60,8 +60,10 @@ public:
        void Read(LyXLex & lex);
        /// 
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index f8348852c5dce899e2312e76a6042fe726a5a75b..38d2cf1f21a467d4ddc9f673df2758e7655af64f 100644 (file)
@@ -99,16 +99,18 @@ void InsetText::Write(ostream & os) const
     WriteParagraphData(os);
 }
 
+
 void InsetText::WriteParagraphData(ostream & os) const
 {
     par->writeFile(os, buffer->params, 0, 0);
 }
 
+
 void InsetText::Read(LyXLex & lex)
 {
     string token, tmptok;
     int pos = 0;
-    LyXParagraph *return_par = 0;
+    LyXParagraph * return_par = 0;
     char depth = 0; // signed or unsigned?
     LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
     LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
@@ -425,8 +427,9 @@ void InsetText::InsetKeyPress(XKeyEvent * xke)
 }
 
 
-UpdatableInset::RESULT InsetText::LocalDispatch(BufferView * bv,
-                                               int action, string const & arg)
+UpdatableInset::RESULT
+InsetText::LocalDispatch(BufferView * bv,
+                        int action, string const & arg)
 {
     no_selection = false;
     if (UpdatableInset::LocalDispatch(bv, action, arg)) {
@@ -590,22 +593,32 @@ UpdatableInset::RESULT InsetText::LocalDispatch(BufferView * bv,
 }
 
 
-int InsetText::Latex(ostream & os, signed char fragile) const
+int InsetText::Latex(ostream & os, signed char /*fragile*/) const
 {
+#ifdef USE_OSTREAM_ONLY
+       string fstr;
+       TexRow texrow;
+       int ret = par->SimpleTeXOnePar(fstr, texrow);
+       os << fstr;
+       return ret;
+#else
     string fstr;
 
     int i = Latex(fstr, fragile);
     os << fstr;
     return i;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetText::Latex(string & file, signed char /* fragile */) const
 {
     TexRow texrow;
 
     return par->SimpleTeXOnePar(file, texrow);
 }
+#endif
 
 
 void InsetText::Validate(LaTeXFeatures & features) const
index 7220ad84167f569b3dff7dd9cc8e1f6abdf104a0..b1b1ae94dd81e2a9c50844b23df02aa8df0937fd 100644 (file)
@@ -81,8 +81,10 @@ public:
     UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
     ///
     int Latex(ostream &, signed char) const;
+#ifndef USE_OSTREAM_ONLY
     ///
     int Latex(string &, signed char) const;
+#endif
     ///
     int Linuxdoc(string &) const { return 0; }
     ///
index af469908377cd70c9deaff0e6f2ce20d089569c6..9416d82660695e8b8fc3b8f3a86d43bfaa57021d 100644 (file)
@@ -168,14 +168,24 @@ string InsetUrl::getScreenLabel() const
 
 int InsetUrl::Latex(ostream & os, signed char fragile) const
 {
+#ifdef USE_OSTREAM_ONLY
+       if (!getOptions().empty())
+               os << getOptions() + ' ';
+       if (fragile)
+               os << "\\protect";
+       os << "\\url{" << getContents() << '}';
+       return 0;
+#else
        string latex_output;
        int res = Latex(latex_output, fragile);
        os << latex_output;
 
        return res;
+#endif
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetUrl::Latex(string & file, signed char fragile) const
 {
        if (!getOptions().empty())
@@ -187,6 +197,7 @@ int InsetUrl::Latex(string & file, signed char fragile) const
 
        return 0;
 }
+#endif
 
 
 int InsetUrl::Linuxdoc(string & file) const
index c60de849fdec6c72fd01da338c5126dfe0af2cf7..f6f84f4acfd9091ca0aa72b042f97e993049c81f 100644 (file)
@@ -71,8 +71,10 @@ public:
         void gotoLabel();
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index c0db3273dcf1ae1428f22fa68703960256122123..5c3b3ee9083810f42ee3a6825c5bc30d63260b56 100644 (file)
@@ -26,6 +26,8 @@ class BufferView;
 
 struct LaTeXFeatures;
 
+#define USE_OSTREAM_ONLY 1
+
 /// Insets
 class Inset {
 public:
@@ -113,8 +115,10 @@ public:
         fragile commands by adding a \protect before.
         */
        virtual int Latex(ostream &, signed char fragile) const = 0;
+#ifndef USE_OSTREAM_ONLY
        ///
        virtual int Latex(string & file, signed char fragile) const = 0;
+#endif
        ///
        virtual int Linuxdoc(string & /*file*/) const = 0;
        ///
index 437ca99d0951ccd4ee2eda181c94824a1f3b93ec..4e0d1f94942bc08c671abe7847ddf4bf3b373983 100644 (file)
@@ -20,6 +20,7 @@
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
+#include <clocale>
 
 #include "debug.h"
 
index e2e957533a9a98fa98708e3ddd49fcf0ac7a018b..d98625962f301f36ed65c62fe889c895c6b741fe 100644 (file)
@@ -59,7 +59,8 @@ int MathedInset::df_des;
 int MathedInset::df_width;
 
 
-inline bool IsMacro(short token, int id)
+inline
+bool IsMacro(short token, int id)
 {
    return (token != LM_TK_FRAC && token != LM_TK_SQRT &&
          !((token == LM_TK_SYM || token == LM_TC_BSYM) && id < 255));
@@ -147,7 +148,7 @@ void mathed_init_fonts() //removed 'static' because DEC cxx does not
 
     Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
                                 //at once (JMarc) rc
-    for (int i = 0 ; i < 8 ; ++i){ 
+    for (int i = 0 ; i < 8 ; ++i) 
        Math_Fonts[i] = LyXFont(LyXFont::ALL_SANE);
     }
     Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
@@ -307,12 +308,21 @@ int InsetFormula::Latex(ostream & os, signed char fragile) const
 //#warning Alejandro, the number of lines is not returned in this case
 // This problem will disapear at 0.13.
     string output;
+#ifdef USE_OSTREAM_ONLY
+    if (fragile < 0)
+           par->Write(output);
+    else
+           mathed_write(par, output, &ret, fragile, label.c_str());
+    
+#else
     InsetFormula::Latex(output, fragile);
+#endif
     os << output;
     return ret;
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetFormula::Latex(string & file, signed char fragile) const
 {
     int ret = 0;
@@ -324,6 +334,7 @@ int InsetFormula::Latex(string & file, signed char fragile) const
         mathed_write(par, file, &ret, fragile, label.c_str());
     return ret;
 }
+#endif
 
 
 int InsetFormula::Linuxdoc(string &/*file*/) const
index 551ab6b2c45d0bb991c26d45c9150e7671cb3a89..7c87264e5016e374e16b41a185f6871267361a5a 100644 (file)
@@ -50,8 +50,10 @@ public:
        void Read(LyXLex & lex);
        ///
        int Latex(ostream &, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index 0b5d5025a69af295ae53f7846e177c39ec8b26bf..d971ac8b2bfa18b9fd125275a5b6b3cd57de65a1 100644 (file)
@@ -78,12 +78,14 @@ int InsetFormulaMacro::Latex(ostream & os, signed char /*fragile*/) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetFormulaMacro::Latex(string &file, signed char /*fragile*/) const
 {
     int ret = 1;
     tmacro->WriteDef(file);
     return ret;
 }
+#endif
 
 
 int InsetFormulaMacro::Linuxdoc(string &/*file*/) const
index b4a76021fb7060663404cd5ac999e91e592e3d03..8b9a6ae6c19469dcfbfa13513c387777915a68e3 100644 (file)
@@ -49,8 +49,10 @@ public:
        void Write(ostream & os) const;
        ///
        int Latex(ostream & os, signed char fragile) const;
+#ifndef USE_OSTREAM_ONLY
        ///
        int Latex(string & file, signed char fragile) const;
+#endif
        ///
        int Linuxdoc(string & file) const;
        ///
index a5fb789cce7f7202f07fd89f1902c8c081535208..d13408c8ff24e7478c5a4aa9587d873cbbf90c35 100644 (file)
@@ -65,11 +65,13 @@ binary_op_pair binary_op_table[] = {
 
 struct compara {
        // used by sort
+       inline
        int operator()(binary_op_pair const & a,
                       binary_op_pair const & b) const {
                return a.id < b.id;
        }
        // used by lower_bound
+       inline
        int operator()(binary_op_pair const & a, short int id) const {
                return a.id < id;
        }
@@ -78,7 +80,8 @@ struct compara {
 
 int MathedLookupBOP(short id)
 {
-       static int bopCount = sizeof(binary_op_table) / sizeof(binary_op_pair);
+       static int const bopCount =
+               sizeof(binary_op_table) / sizeof(binary_op_pair);
        static bool issorted = false;
        
        if (!issorted) {
@@ -89,7 +92,7 @@ int MathedLookupBOP(short id)
        binary_op_pair * res = lower_bound(binary_op_table,
                                           binary_op_table + bopCount,
                                           id, compara());
-       if (res->id == id)
+       if (res != binary_op_table + bopCount && res->id == id)
                return res->isrel;
        else
                return LMB_NONE;
index 2504a391ba08bfa72f953aadc39ddd05e133c473..7da6e8ce0a9a1519659800db2cb4a30e94cde368 100644 (file)
@@ -1930,9 +1930,24 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
                file += style.latexparam();
                break;
        case LATEX_ITEM_ENVIRONMENT:
-               if (bibkey) 
+               if (bibkey) {
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       bibkey->Latex(ost, false);
+                       file += ost.str().c_str();
+#else
+                       ostrstream ost;
+                       bibkey->Latex(ost, false);
+                       ost << '\0';
+                       char * tmp = ost.str();
+                       file += tmp;
+                       delete [] tmp;
+#endif
+#else
                        bibkey->Latex(file, false);
-               else
+#endif
+               } else
                        file += "\\item ";
                break;
        case LATEX_LIST_ENVIRONMENT:
@@ -2942,7 +2957,22 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
                                file += "\\L{";
                                close = true;
                        }
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                       ostringstream ost;
+                       int tmp = inset->Latex(ost, style.isCommand());
+                       file += ost.str().c_str();
+#else
+                       ostrstream ost;
+                       int tmp = inset->Latex(ost, style.isCommand());
+                       ost << '\0';
+                       char * chtmp = ost.str();
+                       file += chtmp;
+                       delete [] chtmp;
+#endif         
+#else
                        int tmp = inset->Latex(file, style.isCommand());
+#endif
                        if (close)
                                file += "}";
                        
index a19bc74f0322778753d78a3d58ab69e1a4ade1f7..9f1f1061a663ea97ff67ad1bb623d0a926f82032 100644 (file)
@@ -1025,6 +1025,25 @@ string findtexfile(string const & fil, string const & /*format*/)
                return MakeAbsPath(fil);
 
         // No we try to find it using kpsewhich.
+       // It seems from the kpsewhich manual page that it is safe to use
+       // kpsewhich without --format: "When the --format option is not
+       // given, the search path used when looking for a file is inferred
+       // from the name given, by looking for a known extension. If no
+       // known extension is found, the search path for TeX source files
+       // is used."
+       // However, we want to take advantage of the format sine almost all
+       // the different formats has environment variables that can be used
+       // to controll which paths to search. f.ex. bib looks in
+       // BIBINPUTS and TEXBIB. Small list follows:
+       // bib - BIBINPUTS, TEXBIB
+       // bst - BSTINPUTS
+       // graphic/figure - TEXPICTS, TEXINPUTS
+       // ist - TEXINDEXSTYLE, INDEXSTYLE
+       // pk - PROGRAMFONTS, PKFONTS, TEXPKS, GLYPHFONTS, TEXFONTS
+       // tex - TEXINPUTS
+       // tfm - TFMFONTS, TEXFONTS
+       // This means that to use kpsewhich in the best possible way we
+       // should help it by setting additional path in the approp. envir.var.
         string kpsecmd = "kpsewhich " + fil;
 
         cmdret c = do_popen(kpsecmd);
index 2bc2b48923f0533f9b78d0a9ac8035536f2e94bb..e987c967655f33ead6c58c5327f94d6a3a027d5b 100644 (file)
@@ -2958,18 +2958,39 @@ char * LyXText::SelectNextWord(float & value)
        /* Start the selection from here */
        sel_cursor = cursor;
 
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+       ostringstream latex;
+#else
+       ostrstream latex;
+#endif
+#else
        string latex;
-   
+#endif
        /* and find the end of the word 
           (optional hyphens are part of a word) */
        while (cursor.pos < cursor.par->Last()
               && (cursor.par->IsLetter(cursor.pos)) 
-                  || (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET &&
-                      cursor.par->GetInset(cursor.pos) != 0 &&
-                      cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0 &&
-                      latex == "\\-"))
+                  || (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
+                      && cursor.par->GetInset(cursor.pos) != 0
+                      && cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                      && latex.str() == "\\-"
+#else
+               && string(latex.str(), 3) == "\\-" // this is not nice at all
+#endif
+#else
+                      && latex == "\\-"
+#endif
+                          ))
                cursor.pos++;
 
+#ifdef USE_OSTREAM_ONLY
+#ifndef HAVE_SSTREAM
+       delete [] latex.str();
+#endif
+#endif
        // Finally, we copy the word to a string and return it
        char * str = 0;
 
@@ -2995,17 +3016,39 @@ void LyXText::SelectSelectedWord()
        /* set the sel cursor */
        sel_cursor = cursor;
 
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+       ostringstream latex;
+#else
+       ostrstream latex;
+#endif
+#else
        string latex;
+#endif
        
        /* now find the end of the word */
        while (cursor.pos < cursor.par->Last()
               && (cursor.par->IsLetter(cursor.pos)
-                  || (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET &&
-                      cursor.par->GetInset(cursor.pos) != 0 &&
-                      cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0 &&
-                      latex == "\\-")))
+                  || (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET
+                      && cursor.par->GetInset(cursor.pos) != 0
+                      && cursor.par->GetInset(cursor.pos)->Latex(latex, 0) == 0
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+                      && latex.str() == "\\-"
+#else
+                      && string(latex.str(), 3) == "\\-"
+#endif
+#else
+                      && latex == "\\-"
+#endif
+                          )))
                cursor.pos++;
        
+#ifdef USE_OSTREAM_ONLY
+#ifndef HAVE_SSTREAM
+       delete [] latex.str();
+#endif
+#endif
        SetCursor(cursor.par, cursor.pos);
        
        /* finally set the selection */ 
@@ -4149,7 +4192,7 @@ int LyXText::GetColumnNearX(Row * row, int & x) const
        LyXDirection direction = row->par->getParDirection();
        LyXParagraph::size_type vc = row->pos;
        LyXParagraph::size_type last = RowLast(row);
-       LyXParagraph::size_type c;
+       LyXParagraph::size_type c = 0;
 
        LyXLayout const & layout = textclasslist.Style(parameters->textclass,
                                                       row->par->GetLayout());