The Noop thing works like magic. I do not understand how it handles
enable/disable and makrDirty though.

>> I would like also to have an adaptation of your patch to remove
>> USE_COMPRESSION, if you can do that for me.

Patch 1: Remove USE_COMPRESSION for 1.4
Patch 2: LFUN_TOGGLE_COMPRESSION for 1.5
Patch 3: LFUN_TOGGLE_COMPRESSION for 1.4 (It is accumulative to patch
1, my laziness)

OK to go in? (You may want to apply patch3 and test for 1.4 though).

Bo
Index: src/lyxlex_pimpl.C
===================================================================
--- src/lyxlex_pimpl.C	(revision 13775)
+++ src/lyxlex_pimpl.C	(working copy)
@@ -140,7 +140,6 @@
 	if (format == "gzip" || format == "zip" || format == "compress") {
 		lyxerr[Debug::LYXLEX] << "lyxlex: compressed" << endl;
 
-#ifdef USE_COMPRESSION
 		// 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)
@@ -152,9 +151,6 @@
 		name = filename;
 		lineno = 0;
 		return gz_.is_open() && is.good();
-#else
-		return false;
-#endif
 	} else {
 		lyxerr[Debug::LYXLEX] << "lyxlex: UNcompressed" << endl;
 
Index: src/buffer.C
===================================================================
--- src/buffer.C	(revision 13775)
+++ src/buffer.C	(working copy)
@@ -67,9 +67,7 @@
 #include "support/lyxalgo.h"
 #include "support/filetools.h"
 #include "support/fs_extras.h"
-#ifdef USE_COMPRESSION
 # include "support/gzstream.h"
-#endif
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/path.h"
@@ -734,15 +732,11 @@
 	bool retval = false;
 
 	if (params().compressed) {
-#ifdef USE_COMPRESSION
 		gz::ogzstream ofs(fname.c_str(), ios::out|ios::trunc);
 		if (!ofs)
 			return false;
 
 		retval = do_writeFile(ofs);
-#else
-		return false;
-#endif
 	} else {
 		ofstream ofs(fname.c_str(), ios::out|ios::trunc);
 		if (!ofs)
Index: src/lyxlex_pimpl.h
===================================================================
--- src/lyxlex_pimpl.h	(revision 13775)
+++ src/lyxlex_pimpl.h	(working copy)
@@ -14,9 +14,7 @@
 
 #include "lyxlex.h"
 
-#ifdef USE_COMPRESSION
 # include "support/gzstream.h"
-#endif
 
 #include <boost/utility.hpp>
 
@@ -61,10 +59,8 @@
 	/// fb_ is only used to open files, the stream is accessed through is.
 	std::filebuf fb_;
 
-#ifdef USE_COMPRESSION
 	/// gz_ is only used to open files, the stream is accessed through is.
 	gz::gzstreambuf gz_;
-#endif
 
 	/// the stream that we use.
 	std::istream is;
Index: src/support/Makefile.am
===================================================================
--- src/support/Makefile.am	(revision 13775)
+++ src/support/Makefile.am	(working copy)
@@ -9,10 +9,6 @@
 
 noinst_LTLIBRARIES = libsupport.la
 
-if USE_COMPRESSION
-COMPRESSION = gzstream.C gzstream.h
-endif
-
 BUILT_SOURCES = $(PCH_FILE) package.C
 
 AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
@@ -46,7 +42,9 @@
 	fs_extras.C \
 	fs_extras.h \
 	getcwd.C \
-	$(COMPRESSION) kill.C \
+	gzstream.C \
+	gzstream.h \
+	kill.C \
 	limited_stack.h \
 	lstrings.C \
 	lstrings.h \
Index: src/tex2lyx/Makefile.am
===================================================================
--- src/tex2lyx/Makefile.am	(revision 13775)
+++ src/tex2lyx/Makefile.am	(working copy)
@@ -20,9 +20,7 @@
 
 BOOST_LIBS = $(BOOST_REGEX) $(BOOST_FILESYSTEM)
 
-if USE_COMPRESSION
 COMPRESSIONLIB = -lz
-endif
 
 LINKED_FILES = \
 	FloatList.C \
Index: configure.ac
===================================================================
--- configure.ac	(revision 13775)
+++ configure.ac	(working copy)
@@ -253,26 +253,11 @@
 # Check the form of mkdir()
 AC_FUNC_MKDIR
 
-AC_ARG_ENABLE(compression-support, AC_HELP_STRING([--enable-compression-support],[Support for compressed files.]),[
-    case "${enableval}" in
-	yes) use_compression=true ;;
-	no) use_compression=false ;;
-	*) AC_MSG_ERROR(bad value ${enableval} for --enable-compression-support) ;;
-    esac
-],[use_compression=true])
-if test $use_compression=true ; then
-	AC_CHECK_HEADERS(zlib.h, use_compression=true, use_compression=false)
-	AC_CHECK_LIB(z, gzopen,[use_compression=true;LIBS="$LIBS -lz"], use_compression=false)
-	if test $use_compression = true ; then
-		AC_DEFINE(USE_COMPRESSION, 1, [Define as 1 if you want to support compressed files.])
-		lyx_flags="compression $lyx_flags"
-	fi
-fi
-AM_CONDITIONAL(USE_COMPRESSION, test x$use_compression = xtrue)
-AC_MSG_CHECKING([whether to support compressed files])
-AC_MSG_RESULT($use_compression)
+# check for compression support
+AC_CHECK_HEADERS(zlib.h,
+ [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_ERROR([zlib not found!]))],
+ [LYX_ERROR([zlib.h not found!])])
 
-
 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: ChangeLog
===================================================================
--- ChangeLog	(revision 13775)
+++ ChangeLog	(working copy)
@@ -1,3 +1,6 @@
+2006-04-28  Bo Peng <[EMAIL PROTECTED]>
+	* remove USE_COMPRESSION
+
 2006-04-27  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* configure.ac: do not run lib/configure.py




Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C	(revision 13776)
+++ src/LyXAction.C	(working copy)
@@ -110,6 +110,7 @@
 		{ LFUN_BEGINNINGBUFSEL, "buffer-begin-select", ReadOnly },
 		{ LFUN_CHILDOPEN, "buffer-child-open", ReadOnly },
 		{ LFUN_RUNCHKTEX, "buffer-chktex", ReadOnly },
+		{ LFUN_TOGGLE_COMPRESSION, "toggle-compression", Noop},
 		{ LFUN_CLOSEBUFFER, "buffer-close", ReadOnly },
 		{ LFUN_ENDBUF, "buffer-end", ReadOnly },
 		{ LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly },
Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C	(revision 13776)
+++ src/BufferView_pimpl.C	(working copy)
@@ -1124,6 +1124,12 @@
 	case LFUN_REJECT_ALL_CHANGES:
 		flag.enabled(buffer_ && buffer_->params().tracking_changes);
 		break;
+
+	case LFUN_TOGGLE_COMPRESSION: {
+		flag.setOnOff(buffer_->params().compressed);
+		break;
+	}
+
 	default:
 		flag.enabled(false);
 	}
@@ -1395,6 +1401,12 @@
 		Alert::information(_("Count words"), message);
 	}
 		break;
+
+	case LFUN_TOGGLE_COMPRESSION:
+		// turn compression on/off
+		buffer_->params().compressed = !buffer_->params().compressed;
+		break;
+
 	default:
 		return false;
 	}
Index: src/lfuns.h
===================================================================
--- src/lfuns.h	(revision 13776)
+++ src/lfuns.h	(working copy)
@@ -365,6 +365,7 @@
 	// 275
 	LFUN_PARAGRAPH_MOVE_DOWN,                // Edwin 20060408
 	LFUN_PARAGRAPH_MOVE_UP,                  // Edwin 20060408
+	LFUN_TOGGLE_COMPRESSION,                 // bpeng 20060427
 
 	LFUN_LASTACTION                  // end of the table
 };
Index: lib/ui/stdmenus.ui
===================================================================
--- lib/ui/stdmenus.ui	(revision 13776)
+++ lib/ui/stdmenus.ui	(working copy)
@@ -381,6 +381,7 @@
 		Item "LaTeX Preamble...|P" "dialog-show preamble"
 		Item "Start Appendix Here|A" "appendix"
 		Separator
+		Item "Compressed|o" "toggle-compression"
 		Item "Settings...|S" "dialog-show document"
 	End
 


Index: src/LyXAction.C
===================================================================
--- src/LyXAction.C	(revision 13775)
+++ src/LyXAction.C	(working copy)
@@ -110,6 +110,7 @@
 		{ LFUN_BEGINNINGBUFSEL, "buffer-begin-select", ReadOnly },
 		{ LFUN_CHILDOPEN, "buffer-child-open", ReadOnly },
 		{ LFUN_RUNCHKTEX, "buffer-chktex", ReadOnly },
+		{ LFUN_TOGGLE_COMPRESSION, "toggle-compression", Noop},
 		{ LFUN_CLOSEBUFFER, "buffer-close", ReadOnly },
 		{ LFUN_ENDBUF, "buffer-end", ReadOnly },
 		{ LFUN_ENDBUFSEL, "buffer-end-select", ReadOnly },
Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C	(revision 13775)
+++ src/BufferView_pimpl.C	(working copy)
@@ -1087,6 +1087,12 @@
 	case LFUN_REJECT_ALL_CHANGES:
 		flag.enabled(buffer_ && buffer_->params().tracking_changes);
 		break;
+
+	case LFUN_TOGGLE_COMPRESSION: {
+		flag.setOnOff(buffer_->params().compressed);
+		break;
+	}
+
 	default:
 		flag.enabled(false);
 	}
@@ -1335,6 +1341,12 @@
 		Alert::information(_("Count words"), message);
 	}
 		break;
+
+	case LFUN_TOGGLE_COMPRESSION:
+		// turn compression on/off
+		buffer_->params().compressed = !buffer_->params().compressed;
+		break;
+
 	default:
 		return false;
 	}
Index: src/lyxlex_pimpl.C
===================================================================
--- src/lyxlex_pimpl.C	(revision 13775)
+++ src/lyxlex_pimpl.C	(working copy)
@@ -140,7 +140,6 @@
 	if (format == "gzip" || format == "zip" || format == "compress") {
 		lyxerr[Debug::LYXLEX] << "lyxlex: compressed" << endl;
 
-#ifdef USE_COMPRESSION
 		// 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)
@@ -152,9 +151,6 @@
 		name = filename;
 		lineno = 0;
 		return gz_.is_open() && is.good();
-#else
-		return false;
-#endif
 	} else {
 		lyxerr[Debug::LYXLEX] << "lyxlex: UNcompressed" << endl;
 
Index: src/buffer.C
===================================================================
--- src/buffer.C	(revision 13775)
+++ src/buffer.C	(working copy)
@@ -67,9 +67,7 @@
 #include "support/lyxalgo.h"
 #include "support/filetools.h"
 #include "support/fs_extras.h"
-#ifdef USE_COMPRESSION
 # include "support/gzstream.h"
-#endif
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/path.h"
@@ -734,15 +732,11 @@
 	bool retval = false;
 
 	if (params().compressed) {
-#ifdef USE_COMPRESSION
 		gz::ogzstream ofs(fname.c_str(), ios::out|ios::trunc);
 		if (!ofs)
 			return false;
 
 		retval = do_writeFile(ofs);
-#else
-		return false;
-#endif
 	} else {
 		ofstream ofs(fname.c_str(), ios::out|ios::trunc);
 		if (!ofs)
Index: src/lyxlex_pimpl.h
===================================================================
--- src/lyxlex_pimpl.h	(revision 13775)
+++ src/lyxlex_pimpl.h	(working copy)
@@ -14,9 +14,7 @@
 
 #include "lyxlex.h"
 
-#ifdef USE_COMPRESSION
 # include "support/gzstream.h"
-#endif
 
 #include <boost/utility.hpp>
 
@@ -61,10 +59,8 @@
 	/// fb_ is only used to open files, the stream is accessed through is.
 	std::filebuf fb_;
 
-#ifdef USE_COMPRESSION
 	/// gz_ is only used to open files, the stream is accessed through is.
 	gz::gzstreambuf gz_;
-#endif
 
 	/// the stream that we use.
 	std::istream is;
Index: src/support/Makefile.am
===================================================================
--- src/support/Makefile.am	(revision 13775)
+++ src/support/Makefile.am	(working copy)
@@ -9,10 +9,6 @@
 
 noinst_LTLIBRARIES = libsupport.la
 
-if USE_COMPRESSION
-COMPRESSION = gzstream.C gzstream.h
-endif
-
 BUILT_SOURCES = $(PCH_FILE) package.C
 
 AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
@@ -46,7 +42,9 @@
 	fs_extras.C \
 	fs_extras.h \
 	getcwd.C \
-	$(COMPRESSION) kill.C \
+	gzstream.C \
+	gzstream.h \
+	kill.C \
 	limited_stack.h \
 	lstrings.C \
 	lstrings.h \
Index: src/lfuns.h
===================================================================
--- src/lfuns.h	(revision 13775)
+++ src/lfuns.h	(working copy)
@@ -357,6 +357,7 @@
 	LFUN_BIBDB_ADD,
 	LFUN_BIBDB_DEL,
 	LFUN_INSERT_CITATION,
+	LFUN_TOGGLE_COMPRESSION,         // bpeng 20060427
 
 	LFUN_LASTACTION                  // end of the table
 };
Index: src/tex2lyx/Makefile.am
===================================================================
--- src/tex2lyx/Makefile.am	(revision 13775)
+++ src/tex2lyx/Makefile.am	(working copy)
@@ -20,9 +20,7 @@
 
 BOOST_LIBS = $(BOOST_REGEX) $(BOOST_FILESYSTEM)
 
-if USE_COMPRESSION
 COMPRESSIONLIB = -lz
-endif
 
 LINKED_FILES = \
 	FloatList.C \
Index: configure.ac
===================================================================
--- configure.ac	(revision 13775)
+++ configure.ac	(working copy)
@@ -253,26 +253,11 @@
 # Check the form of mkdir()
 AC_FUNC_MKDIR
 
-AC_ARG_ENABLE(compression-support, AC_HELP_STRING([--enable-compression-support],[Support for compressed files.]),[
-    case "${enableval}" in
-	yes) use_compression=true ;;
-	no) use_compression=false ;;
-	*) AC_MSG_ERROR(bad value ${enableval} for --enable-compression-support) ;;
-    esac
-],[use_compression=true])
-if test $use_compression=true ; then
-	AC_CHECK_HEADERS(zlib.h, use_compression=true, use_compression=false)
-	AC_CHECK_LIB(z, gzopen,[use_compression=true;LIBS="$LIBS -lz"], use_compression=false)
-	if test $use_compression = true ; then
-		AC_DEFINE(USE_COMPRESSION, 1, [Define as 1 if you want to support compressed files.])
-		lyx_flags="compression $lyx_flags"
-	fi
-fi
-AM_CONDITIONAL(USE_COMPRESSION, test x$use_compression = xtrue)
-AC_MSG_CHECKING([whether to support compressed files])
-AC_MSG_RESULT($use_compression)
+# check for compression support
+AC_CHECK_HEADERS(zlib.h,
+ [AC_CHECK_LIB(z, gzopen, [LIBS="$LIBS -lz"], LYX_ERROR([zlib not found!]))],
+ [LYX_ERROR([zlib.h not found!])])
 
-
 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: lib/ui/stdmenus.ui
===================================================================
--- lib/ui/stdmenus.ui	(revision 13775)
+++ lib/ui/stdmenus.ui	(working copy)
@@ -380,6 +380,7 @@
 		Item "LaTeX Preamble...|P" "dialog-show preamble"
 		Item "Start Appendix Here|A" "appendix"
 		Separator
+		Item "Compressed|o" "toggle-compression"
 		Item "Settings...|S" "dialog-show document"
 	End
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13775)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2006-04-28  Bo Peng <[EMAIL PROTECTED]>
+	* add document->compressed menu item
+
+2006-04-28  Bo Peng <[EMAIL PROTECTED]>
+	* remove USE_COMPRESSION
+
 2006-04-27  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* configure.ac: do not run lib/configure.py

Reply via email to