]> git.lyx.org Git - lyx.git/commitdiff
more compress support
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 28 Jul 2003 14:40:29 +0000 (14:40 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 28 Jul 2003 14:40:29 +0000 (14:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7419 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
ChangeLog
configure.ac
src/ChangeLog
src/Makefile.am
src/buffer.C
src/buffer.h
src/buffer_funcs.C
src/bufferparams.C
src/bufferparams.h
src/insets/insetgraphics.C
src/insets/insettext.C
src/lyxlex_pimpl.C
src/paragraph.C
src/text.C
src/text3.C

index 3a080ae916bb3604faeef79313b3513bdb82f1ea..5562248fff4326a7fa0b47645996f65a1ee64672 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-28  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * configure.ac: check for zlib.
+
 2003-07-27  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * configure.ac: new file
index a0f114b98feffc0719f8696efc85740b1f450732..20ee16626847430ce2f342475ebdf39521d9943d 100644 (file)
@@ -246,6 +246,9 @@ LYX_CHECK_DECL(vsnprintf, stdio.h)
 LYX_CHECK_DECL(istreambuf_iterator, iterator)
 LYX_CHECK_DECL(mkstemp,[unistd.h stdlib.h])
 
+AC_CHECK_HEADERS(zlib.h)
+AC_CHECK_LIB(z, gzopen)
+
 dnl This is a slight hack: the tests generated by autoconf 2.52 do not
 dnl work correctly because of some conflict with stdlib.h with g++ 2.96
 dnl We aim to remove this eventually, since we should test as much as
index c2073ae59a49f3315c1633b0577bb78d8135e8a4..dacc8eae5fa4fa9cfdf65ca585ac872a3eedb400 100644 (file)
@@ -1,10 +1,26 @@
+2003-07-28  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * lyxlex_pimpl.C (setFile): clean up slightly.
+
+       * bufferparams.h: add compressed var
+
+       * buffer_funcs.C (readFile): adjust for LyXLex change
+       (newFile): ditto + simplify
+
+       * buffer.C (writeFile): handle writing of compressed files
+
+       * buffer.[Ch] (readFile): begin LyXLex here, remove one argument.
+       Check if the file is compressed and set a bufferparm if so.
+
+       * Makefile.am (lyx_LDADD): remove explicit -lz
+
 2003-07-28  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * buffer.C (do_writeFile, makeLaTeXFile, makeLinuxDocFile,
        makeDocBookFile): put the real LyX version in the first line of
        the file
 
-       * version.h: 
+       * version.h:
        * version.C.in: remove lyx_docversion
 
        * tabular.C (write_attribute): add a template-based version to
index 782df6578a6737544d620a4803d45aa5957628f0..81b9e7f1b73baed245a843550d59606bd2641f3f 100644 (file)
@@ -31,7 +31,7 @@ BOOST_LIBS = -lboost_regex -lboost_signals
 endif
 
 lyx_LDADD = $(LYX_CONV_LIBS) $(BOOST_LIBS) $(INTLLIBS) \
-       $(AIKSAURUS_LIBS) @LIBS@ -lz
+       $(AIKSAURUS_LIBS) @LIBS@
 
 lyx_DEPENDENCIES = $(LYX_CONV_LIBS) $(BOOST_LIBS) $(INTLLIBS)
 
index 6ffdecd0563907d9a8209f79d783bc135e90bd10..9ac61660dc9ba5c22b69293a7e7ae0559a54a658 100644 (file)
@@ -440,8 +440,17 @@ void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
 }
 
 
-bool Buffer::readFile(LyXLex & lex, string const & filename)
+bool Buffer::readFile(string const & filename)
 {
+       // Check if the file is compressed.
+       string const format = getExtFromContents(filename);
+       if (format == "gzip" || format == "zip" || format == "compress") {
+               params.compressed = true;
+       }
+
+       LyXLex lex(0, 0);
+       lex.setFile(filename);
+
        bool ret = readFile(lex, filename, paragraphs.begin());
 
        // After we have read a file, we must ensure that the buffer
@@ -637,23 +646,25 @@ bool Buffer::writeFile(string const & fname) const
                return false;
        }
 
-       bool const compressed = (fname.substr(fname.size() - 3, 3) == ".gz");
+       bool retval;
 
-       if (compressed) {
+       if (params.compressed) {
                gz::ogzstream ofs(fname.c_str());
 
                if (!ofs)
                        return false;
 
-               return do_writeFile(ofs);
+               retval = do_writeFile(ofs);
 
-       }
+       } else {
+               ofstream ofs(fname.c_str());
+               if (!ofs)
+                       return false;
 
-       ofstream ofs(fname.c_str());
-       if (!ofs)
-               return false;
+               retval = do_writeFile(ofs);
+       }
 
-       return do_writeFile(ofs);
+       return retval;
 }
 
 
index 60c98c841b8579ce0bfd0d4ea81cbb8b7e02d224..4c28a12014c28e46d2a95492102ba179103c3948 100644 (file)
@@ -80,7 +80,7 @@ public:
 
        // FIXME: it's very silly to pass a lex in here
        /// load a new file
-       bool readFile(LyXLex &, string const &);
+       bool readFile(string const &);
 
        /// read the header, returns number of unknown tokens
        int readHeader(LyXLex & lex);
index bf9073fb664393b077a9cda64be3f0e0032d08f3..59b1cfc9e43c65ecd9c150da7bded07b9532dfae 100644 (file)
@@ -18,7 +18,6 @@
 #include "errorlist.h"
 #include "gettext.h"
 #include "vc-backend.h"
-#include "lyxlex.h"
 #include "LaTeX.h"
 #include "ParagraphList.h"
 #include "paragraph.h"
@@ -105,11 +104,7 @@ bool readFile(Buffer * b, string const & s)
                        }
                }
        }
-       // not sure if this is the correct place to begin LyXLex
-       LyXLex lex(0, 0);
-       lex.setFile(ts);
-
-       return b->readFile(lex, ts);
+       return b->readFile(ts);
 }
 
 
@@ -166,17 +161,9 @@ Buffer * newFile(string const & filename, string const & templatename,
                tname = templatename;
 
        if (!tname.empty()) {
-               bool templateok = false;
-               LyXLex lex(0, 0);
-               lex.setFile(tname);
-               if (lex.isOK()) {
-                       if (b->readFile(lex, tname)) {
-                               templateok = true;
-                       }
-               }
-               if (!templateok) {
+               if (!b->readFile(tname)) {
                        string const file = MakeDisplayPath(tname, 50);
-                       string text  = bformat(_("The specified document template\n%1$s\n"
+                       string const text  = bformat(_("The specified document template\n%1$s\n"
                                "could not be read."), file);
                        Alert::error(_("Could not read template"), text);
                        // no template, start with empty buffer
@@ -200,7 +187,7 @@ Buffer * newFile(string const & filename, string const & templatename,
 }
 
 
-void bufferErrors(Buffer const & buf, TeXErrors const & terr) 
+void bufferErrors(Buffer const & buf, TeXErrors const & terr)
 {
        TeXErrors::Errors::const_iterator cit = terr.begin();
        TeXErrors::Errors::const_iterator end = terr.end();
@@ -219,12 +206,12 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr)
 }
 
 
-void bufferErrors(Buffer const & buf, ErrorList const & el) 
+void bufferErrors(Buffer const & buf, ErrorList const & el)
 {
        ErrorList::const_iterator it = el.begin();
        ErrorList::const_iterator end = el.end();
 
-       for (; it != end; ++it) 
+       for (; it != end; ++it)
                buf.error(*it);
 }
 
index d560eaff6c381545889e9ef07d9f13146756cd3e..02b6b677edc319ff20ced88d3e661e2c09770215 100644 (file)
@@ -73,6 +73,7 @@ BufferParams::BufferParams()
        sides = LyXTextClass::OneSide;
        columns = 1;
        pagestyle = "default";
+       compressed = false;
        for (int iter = 0; iter < 4; ++iter) {
                user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
                temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
@@ -1004,7 +1005,7 @@ string const BufferParams::dvips_options() const
                string const paper_option = paperSizeName();
                if (paper_option != "letter" ||
                    orientation != ORIENTATION_LANDSCAPE) {
-                       // dvips won't accept -t letter -t landscape.  
+                       // dvips won't accept -t letter -t landscape.
                        // In all other cases, include the paper size
                        // explicitly.
                        result = lyxrc.print_paper_flag;
index dc0782d5d10101cea2e3d1ddf12df4dfe0adafc6..45bc0fc1600f2e25a416b2cb1f4bb8f8c941714a 100644 (file)
@@ -174,6 +174,8 @@ public:
        bool tracking_changes;
        /// Time ago we agreed that this was a buffer property [ale990407]
        string parentname;
+       ///
+       bool compressed;
 
        /// map of the file's author IDs to buffer author IDs
        std::vector<int> author_map;
index afdaa35a9e14e9e0a9345b7f94127bf1bc9d4437..c2b4a355f7e43ec987f3d1cdb60b42c8b5e72877 100644 (file)
@@ -554,7 +554,7 @@ int InsetGraphics::linuxdoc(Buffer const * buf, ostream & os) const
 {
        string const file_name = buf->niceFile ?
                                params().filename.relFilename(buf->filePath()):
-                               params().filename.absFilename();
+                               params().filename.absFilename();
 
        os << "<eps file=\"" << file_name << "\">\n";
        os << "<img src=\"" << file_name << "\">";
index 4e0e5ea8767cf810b6ce6468b04831d43d3346f3..128065ebe6ffab1c21f174cf0c01a4af70ddc7aa 100644 (file)
@@ -515,7 +515,7 @@ void InsetText::lockInset(BufferView * bv)
 }
 
 
-void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
+void InsetText::lockInset(BufferView * /*bv*/, UpdatableInset * inset)
 {
        the_locking_inset = inset;
        inset_x = cix() - top_x + drawTextXOffset;
@@ -629,7 +629,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, InsetOld * inset)
                                return false;
                        found = tl_inset->updateInsetInInset(bv, inset);
                        ustat = FULL;
-               } else { 
+               } else {
                        text_.updateInset(tl_inset);
                        setUpdateStatus(ustat);
                }
index da7d92d9a3ab2b76c11e49dbe3412217e168165f..8ad57be9d0b9bf41e5cda4544278e75c4f450d4b 100644 (file)
@@ -113,15 +113,16 @@ void LyXLex::Pimpl::popTable()
 
 bool LyXLex::Pimpl::setFile(string const & filename)
 {
-       // Is this a compressed file or not?
-       bool const compressed = (filename.substr(filename.size() - 3, 3) == ".gz");
 
-       // The check only outputs a debug message, because it triggers
-       // a bug in compaq cxx 6.2, where is_open() returns 'true' for a
-       // fresh new filebuf.  (JMarc)
-       if (compressed) {
+       // Check the format of the file.
+       string const format = getExtFromContents(filename);
+
+       if (format == "gzip" || format == "zip" || format == "compress") {
                lyxerr << "lyxlex: compressed" << endl;
 
+               // The check only outputs a debug message, because it triggers
+               // a bug in compaq cxx 6.2, where is_open() returns 'true' for
+               // a fresh new filebuf.  (JMarc)
                if (gz__.is_open() || is.tellg() > 0)
                        lyxerr[Debug::LYXLEX] << "Error in LyXLex::setFile: "
                                "file or stream already set." << endl;
@@ -133,6 +134,9 @@ bool LyXLex::Pimpl::setFile(string const & filename)
        } else {
                lyxerr << "lyxlex: UNcompressed" << endl;
 
+               // The check only outputs a debug message, because it triggers
+               // a bug in compaq cxx 6.2, where is_open() returns 'true' for
+               // a fresh new filebuf.  (JMarc)
                if (fb__.is_open() || is.tellg() > 0)
                        lyxerr[Debug::LYXLEX] << "Error in LyXLex::setFile: "
                                "file or stream already set." << endl;
@@ -142,7 +146,6 @@ bool LyXLex::Pimpl::setFile(string const & filename)
                lineno = 0;
                return fb__.is_open() && is.good();
        }
-
 }
 
 
index a15c8220195050bbd849943e3fe24d714bd6b143..f6982c75aad9fdb6094fc56b5939cb8f1b731831 100644 (file)
@@ -404,8 +404,8 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
 }
 
 
-lyx::pos_type 
-Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const 
+lyx::pos_type
+Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const
 {
        Assert(pos <= size());
 
index 8cec91518d177d653e6496dc15461c5c339ce53d..d9ae8bdafde08653a9a9f942adddaa9ba74d2d12 100644 (file)
@@ -1167,7 +1167,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                                                maxasc = max(maxasc, tmpinset->ascent());
                                                maxdesc = max(maxdesc, tmpinset->descent());
 #endif
-                                       } 
+                                       }
                                } else {
                                        // Fall-back to normal case
                                        maxwidth += singleWidth(pit, pos, c);
index a5a04b9da4784456080be80ee05cb379a597dbb6..a4ef8ec0f419a8dc5a2953d5029f80207208bde8 100644 (file)
@@ -97,7 +97,7 @@ namespace {
        // check if the given co-ordinates are inside an inset at the
        // given cursor, if one exists. If so, the inset is returned,
        // and the co-ordinates are made relative. Otherwise, 0 is returned.
-       InsetOld * checkInset(BufferView * bv, LyXText & text,
+InsetOld * checkInset(BufferView * /*bv*/, LyXText & text,
                LyXCursor const & cur, int & x, int & y)
        {
                lyx::pos_type const pos = cur.pos();