]> git.lyx.org Git - features.git/commitdiff
shuffle (la)texstream around a bit
authorAndré Pönitz <poenitz@gmx.net>
Sun, 12 Aug 2007 14:54:54 +0000 (14:54 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sun, 12 Aug 2007 14:54:54 +0000 (14:54 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19460 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Makefile.am
src/TexRow.h
src/TexStream.cpp
src/TexStream.h

index bc61f08d8e280e9b0364aab8b30d8bc3939c7dc4..c9c3b07e53d6ce892bfa8c3986aa44a9cc16fd7d 100644 (file)
@@ -47,6 +47,7 @@
 #include "ParIterator.h"
 #include "sgml.h"
 #include "TexRow.h"
+#include "TexStream.h"
 #include "TocBackend.h"
 #include "Undo.h"
 #include "version.h"
@@ -920,6 +921,8 @@ bool Buffer::makeLaTeXFile(FileName const & fname,
        if (!openFileWrite(ofs, fname))
                return false;
 
+       //TexStream ts(ofs.rdbuf(), &texrow());
+
        bool failed_export = false;
        try {
                writeLaTeXSource(ofs, original_path,
index a19047db8e0186d05d750f11fef49330ed612ea9..431ebc0e69e8ddf8cc34806764ed94230c0b3d95 100644 (file)
@@ -25,6 +25,8 @@ LYX_POST_LIBS = frontends/controllers/liblyxcontrollers.la \
 
 OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $(AIKSAURUS_LIBS) @LIBS@ $(SOCKET_LIBS)
 
+AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
+
 pkglib_LTLIBRARIES = liblyxcore.la
 noinst_PROGRAMS = $(FRONTENDS_PROGS)
 EXTRA_PROGRAMS = lyx-qt4
@@ -224,6 +226,8 @@ liblyxcore_la_SOURCES = \
        SpellBase.h \
        TexRow.cpp \
        TexRow.h \
+       TexStream.cpp \
+       TexStream.h \
        Text.h \
        Text.cpp \
        Text2.cpp \
@@ -457,8 +461,6 @@ EXTRA_DIST += \
        insets/InsetTheorem.cpp \
        insets/InsetTheorem.h
 
-AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
-
 liblyxinsets_la_SOURCES = \
        insets/MailInset.cpp \
        insets/MailInset.h \
index 24a61c0730817ee2745ee8da886b6c647d10c2be..0dea3d158dcf2d6141ac5f6f09de822abca2395c 100644 (file)
@@ -20,7 +20,9 @@
 namespace lyx {
 
 
-/// Represents the correspondence between paragraphs and the generated LaTeX file
+/// Represents the correspondence between paragraphs and the generated
+//LaTeX file
+
 class TexRow {
 public:
        ///
@@ -60,24 +62,13 @@ public:
                {}
 
                /// paragraph id
-               int id() const {
-                       return id_;
-               }
-
+               int id() const { return id_; }
                /// set paragraph position
-               void pos(int p) {
-                       pos_ = p;
-               }
-
+               void pos(int p) { pos_ = p; }
                /// paragraph position
-               int pos() const {
-                       return pos_;
-               }
-
+               int pos() const { return pos_; }
                /// row number
-               int rownumber() const {
-                       return rownumber_;
-               }
+               int rownumber() const { return rownumber_; }
        private:
                RowItem();
                int id_;
index b3d9f50362b28bda4ffdc185973fcdfa83c5c103..557833dabe8fdb6db5983c36b73f9a9c1013b18b 100644 (file)
@@ -1,4 +1,5 @@
-#include "LaTeXStream.h"
+#include "TexStream.h"
+#include "TexRow.h"
 
 #include <iostream>
 #include <streambuf>
@@ -7,43 +8,50 @@ namespace lyx {
 
 ////////////////////////////////////////////////////////////////
 //
-// LaTeXStreamBuffer
+// TexStreamBuffer
 //
 ////////////////////////////////////////////////////////////////
 
 
-class LaTeXStreamBuffer : public std::streambuf
+class TexStreamBuffer : public TexStreamBase
 {
 public:
-  explicit LaTeXStreamBuffer(std::streambuf * sbuf);
+  TexStreamBuffer(TexStreamBase * sbuf, TexRow * texrow);
        int line() const { return line_; }
+       int column() const { return column_; }
 
 protected:
   int overflow(int);
   int sync();
 
 private:
-  std::streambuf * sbuf_; 
+  TexStreamBase * sbuf_; 
+       TexRow * texrow_;
+       int column_;
        int line_;
 };
 
 
-LaTeXStreamBuffer::LaTeXStreamBuffer(std::streambuf *sb)
-  : sbuf_(sb), line_(0)
+TexStreamBuffer::TexStreamBuffer(TexStreamBase *sb, TexRow * texrow)
+  : sbuf_(sb), texrow_(texrow), line_(0)
 {
   setp(0, 0);
   setg(0, 0, 0);
 }
 
-int LaTeXStreamBuffer::overflow(int c)
+int TexStreamBuffer::overflow(int c)
 {
-       if (c == '\n')
+       if (c == '\n') {
                ++line_;
+               column_ = 0;
+       } else {
+               ++column_;
+       }
        return c;
 }
 
 
-int LaTeXStreamBuffer::sync()
+int TexStreamBuffer::sync()
 {
   sbuf_->pubsync();
   return 0;
@@ -52,22 +60,22 @@ int LaTeXStreamBuffer::sync()
   
 ////////////////////////////////////////////////////////////////
 //
-// LaTeXStream
+// TexStream
 //
 ////////////////////////////////////////////////////////////////
 
-LaTeXStream::LaTeXStream(std::streambuf * sbuf)
-               : std::ostream(sbuf_ = new LaTeXStreamBuffer(sbuf))
+TexStream::TexStream(TexStreamBase * sbuf, TexRow * texrow)
+               : std::basic_ostream<char_type>(sbuf_ = new TexStreamBuffer(sbuf, texrow))
 {}
 
 
-LaTeXStream::~LaTeXStream()
+TexStream::~TexStream()
 {
        delete sbuf_;
 }
 
 
-int LaTeXStream::line() const
+int TexStream::line() const
 {
        return sbuf_->line();
 }
@@ -83,7 +91,7 @@ int LaTeXStream::line() const
 
 int main(int argc, char *argv[])
 {
-       LaTeXStream out(std::cout.rdbuf());
+       TexStream out(std::cout.rdbuf());
        char c;
        while (std::cin) {
                if (std::cin.get(c))
index bdd32fc8771041a7e5f463e92cfc9962bc38d375..9ae20222a6c08dbe00684c17ffc205efcdb73ad3 100644 (file)
@@ -1,21 +1,29 @@
 #ifndef LATEXSTREAM_H
 #define LATEXSTREAM_H
 
+#include "support/docstring.h"
+
+#include "TexRow.h"
+
 #include <iostream>
 #include <streambuf>
 
 namespace lyx {
 
-class LaTeXStreamBuffer;
+class TexStreamBuffer;
+class TexRow;
 
-class LaTeXStream : public std::ostream
+typedef std::basic_streambuf<char_type> TexStreamBase;
+
+class TexStream : public std::basic_ostream<char_type>
 {
 public:
-  LaTeXStream(std::streambuf * sbuf);
-  ~LaTeXStream();
+  TexStream(TexStreamBase * sbuf, TexRow * texrow);
+  ~TexStream();
        int line() const;
+
 private:
-       LaTeXStreamBuffer * sbuf_;
+       TexStreamBuffer * sbuf_;
 };
 
 } // namespace lyx