]> git.lyx.org Git - features.git/blobdiff - src/text.C
change to use only ostream to write latex from insets
[features.git] / src / text.C
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());