From 5c32dc85d54b9cee8ceae77b7e4882447617358f Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 21 Apr 2014 16:50:56 +0200 Subject: [PATCH] Fix various warnings issued by clang++. * remove unused class TexStream. * remove unused virtual method Inset::cellXOffset * remove second argument of FileDialog constructor, which was actually not used * remove some dead local code * remove some unused private members of classes * in InsetMathNest::updateBuffer, fix the logic of a test --- src/Buffer.cpp | 2 - src/BufferParams.cpp | 5 -- src/Cursor.cpp | 16 ---- src/Makefile.am | 2 - src/TexStream.cpp | 121 ------------------------------- src/TexStream.h | 31 -------- src/frontends/qt4/FileDialog.cpp | 4 +- src/frontends/qt4/FileDialog.h | 10 +-- src/frontends/qt4/GuiPrefs.cpp | 4 +- src/frontends/qt4/GuiSymbols.cpp | 5 +- src/frontends/qt4/GuiView.cpp | 13 ++-- src/insets/Inset.h | 4 - src/mathed/InsetMathNest.cpp | 2 +- src/output_xhtml.cpp | 24 +----- src/tex2lyx/Preamble.cpp | 3 - 15 files changed, 15 insertions(+), 231 deletions(-) delete mode 100644 src/TexStream.cpp delete mode 100644 src/TexStream.h diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 51430e44a1..cbd46266e9 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -58,7 +58,6 @@ #include "SpellChecker.h" #include "sgml.h" #include "TexRow.h" -#include "TexStream.h" #include "Text.h" #include "TextClass.h" #include "TocBackend.h" @@ -1501,7 +1500,6 @@ bool Buffer::makeLaTeXFile(FileName const & fname, if (!openFileWrite(ofs, fname)) return false; - //TexStream ts(ofs.rdbuf(), &texrow()); ErrorList & errorList = d->errorLists["Export"]; errorList.clear(); bool failed_export = false; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 454ccbe99c..49c55aaa51 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -87,11 +87,6 @@ static char const * const string_orientation[] = { }; -static char const * const string_footnotekinds[] = { - "footnote", "margin", "fig", "tab", "alg", "wide-fig", "wide-tab", "" -}; - - static char const * const tex_graphics[] = { "default", "dvialw", "dvilaser", "dvipdf", "dvipdfm", "dvipdfmx", "dvips", "dvipsone", "dvitops", "dviwin", "dviwindo", "dvi2ps", "emtex", diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 964b593f23..c74031555f 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -65,22 +65,6 @@ namespace lyx { namespace { -bool positionable(DocIterator const & cursor, DocIterator const & anchor) -{ - // avoid deeper nested insets when selecting - if (cursor.depth() > anchor.depth()) - return false; - - // anchor might be deeper, should have same path then - for (size_t i = 0; i < cursor.depth(); ++i) - if (&cursor[i].inset() != &anchor[i].inset()) - return false; - - // position should be ok. - return true; -} - - // Find position closest to (x, y) in cell given by iter. // Used only in mathed DocIterator bruteFind2(Cursor const & c, int x, int y) diff --git a/src/Makefile.am b/src/Makefile.am index 2a986437f1..d3ea7bc0e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,7 +178,6 @@ SOURCEFILESCORE = \ Text.cpp \ Text2.cpp \ Text3.cpp \ - TexStream.cpp \ TextClass.cpp \ TextMetrics.cpp \ TocBackend.cpp \ @@ -282,7 +281,6 @@ HEADERFILESCORE = \ Spacing.h \ SpellChecker.h \ TexRow.h \ - TexStream.h \ Text.h \ TextClass.h \ TextMetrics.h \ diff --git a/src/TexStream.cpp b/src/TexStream.cpp deleted file mode 100644 index dc1c43c2a9..0000000000 --- a/src/TexStream.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/** - * \file TexStream.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * Full author contact details are available in file CREDITS. - * - * Inspired by Dietmar Kuehl's prefix iostreams found on - * http://www.inf.uni-konstanz.de/~kuehl/ - */ - -#include - -#include "TexStream.h" -#include "TexRow.h" - -#include -#include - -namespace lyx { - -//////////////////////////////////////////////////////////////// -// -// TexStreamBuffer -// -//////////////////////////////////////////////////////////////// - - -class TexStreamBuffer : public TexStreamBase -{ -public: - TexStreamBuffer(TexStreamBase * sbuf, TexRow * texrow); - int line() const { return line_; } - int column() const { return column_; } - -protected: - int_type overflow(int_type); - int sync(); - -private: - TexStreamBase * sbuf_; - TexRow * texrow_; - int column_; - int line_; -}; - - -TexStreamBuffer::TexStreamBuffer(TexStreamBase *sb, TexRow * texrow) - : sbuf_(sb), texrow_(texrow), line_(0) -{ - setp(0, 0); - setg(0, 0, 0); -} - -TexStreamBuffer::int_type TexStreamBuffer::overflow(TexStreamBuffer::int_type c) -{ - if (c == '\n') { - ++line_; - column_ = 0; - } else { - ++column_; - } - return c; -} - - -int TexStreamBuffer::sync() -{ - sbuf_->pubsync(); - return 0; -} - - -//////////////////////////////////////////////////////////////// -// -// TexStream -// -//////////////////////////////////////////////////////////////// - -TexStream::TexStream(TexStreamBase * sbuf, TexRow * texrow) - : std::basic_ostream(sbuf_ = new TexStreamBuffer(sbuf, texrow)) -{} - - -TexStream::~TexStream() -{ - delete sbuf_; -} - - -int TexStream::line() const -{ - return sbuf_->line(); -} - - -//////////////////////////////////////////////////////////////// -// -// Test -// -//////////////////////////////////////////////////////////////// - -#if 0 - -int main(int argc, char *argv[]) -{ - TexStream out(cout.rdbuf()); - char c; - while (cin) { - if (cin.get(c)) - out.put(c); - } - cout << "line count: " << out.line() << endl; - - return 0; -} - -#endif - -} - diff --git a/src/TexStream.h b/src/TexStream.h deleted file mode 100644 index 7c4bdd9d10..0000000000 --- a/src/TexStream.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef TEXSTREAM_H -#define TEXSTREAM_H - -#include "support/docstring.h" - -#include "TexRow.h" - -#include -#include - -namespace lyx { - -class TexStreamBuffer; -class TexRow; - -typedef std::basic_streambuf TexStreamBase; - -class TexStream : public std::basic_ostream -{ -public: - TexStream(TexStreamBase * sbuf, TexRow * texrow); - ~TexStream(); - int line() const; - -private: - TexStreamBuffer * sbuf_; -}; - -} // namespace lyx - -#endif diff --git a/src/frontends/qt4/FileDialog.cpp b/src/frontends/qt4/FileDialog.cpp index 988a8d006b..8f63d2e18a 100644 --- a/src/frontends/qt4/FileDialog.cpp +++ b/src/frontends/qt4/FileDialog.cpp @@ -55,8 +55,8 @@ public: }; -FileDialog::FileDialog(QString const & t, FuncCode s) - : private_(new FileDialog::Private), title_(t), success_(s) +FileDialog::FileDialog(QString const & t) + : private_(new FileDialog::Private), title_(t) {} diff --git a/src/frontends/qt4/FileDialog.h b/src/frontends/qt4/FileDialog.h index d60d9a4b00..99a98369dc 100644 --- a/src/frontends/qt4/FileDialog.h +++ b/src/frontends/qt4/FileDialog.h @@ -13,8 +13,6 @@ #ifndef FILEDIALOG_H #define FILEDIALOG_H -#include "FuncCode.h" - #include #include @@ -42,16 +40,12 @@ public: /** * Constructs a file dialog with title \param title. - * If \param a is \const LFUN_SELECT_FILE_SYNC then a value - * will be returned immediately upon performing a open(), - * otherwise a callback Dispatch() will be invoked with the filename as - * argument, of action \param a. * * Up to two optional extra buttons are allowed for specifying * additional directories in the navigation (an empty * directory is interpreted as FileName::getcwd()) */ - FileDialog(QString const & title, FuncCode a = LFUN_SELECT_FILE_SYNC); + FileDialog(QString const & title); ~FileDialog(); @@ -83,8 +77,6 @@ private: /// the dialog title QString title_; - /// success action to perform if not synchronous - FuncCode success_; }; } // namespace lyx diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index d93124931e..6dfd337dcd 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -112,7 +112,7 @@ QString browseFile(QString const & filename, else if(!fallback_dir.isEmpty()) lastPath = fallback_dir; - FileDialog dlg(title, LFUN_SELECT_FILE_SYNC); + FileDialog dlg(title); dlg.setButton2(label1, dir1); dlg.setButton2(label2, dir2); @@ -183,7 +183,7 @@ QString browseDir(QString const & pathname, if (!pathname.isEmpty()) lastPath = onlyPath(pathname); - FileDialog dlg(title, LFUN_SELECT_FILE_SYNC); + FileDialog dlg(title); dlg.setButton1(label1, dir1); dlg.setButton2(label2, dir2); diff --git a/src/frontends/qt4/GuiSymbols.cpp b/src/frontends/qt4/GuiSymbols.cpp index c9305042ee..1e7e7891bf 100644 --- a/src/frontends/qt4/GuiSymbols.cpp +++ b/src/frontends/qt4/GuiSymbols.cpp @@ -199,7 +199,7 @@ class GuiSymbols::Model : public QAbstractItemModel { public: Model(GuiSymbols * parent) - : QAbstractItemModel(parent), parent_(parent) + : QAbstractItemModel(parent) {} QModelIndex index(int row, int column, QModelIndex const &) const @@ -257,8 +257,7 @@ public: private: friend class GuiSymbols; - GuiSymbols * parent_; - + QList symbols_; }; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 22681f104b..a7cbbe49fe 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1952,7 +1952,7 @@ void GuiView::openDocument(string const & fname) string filename; if (fname.empty()) { - FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN); + FileDialog dlg(qt_("Select document to open")); dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path)); dlg.setButton2(qt_("Examples|#E#e"), toqstr(addPath(package().system_support().absFileName(), "examples"))); @@ -2091,7 +2091,7 @@ void GuiView::importDocument(string const & argument) docstring const text = bformat(_("Select %1$s file to import"), formats.prettyName(format)); - FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT); + FileDialog dlg(toqstr(text)); dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path)); dlg.setButton2(qt_("Examples|#E#e"), toqstr(addPath(package().system_support().absFileName(), "examples"))); @@ -2225,7 +2225,7 @@ void GuiView::insertLyXFile(docstring const & fname) initpath = trypath; // FIXME UNICODE - FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT); + FileDialog dlg(qt_("Select LyX document to insert")); dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path)); dlg.setButton2(qt_("Examples|#E#e"), toqstr(addPath(package().system_support().absFileName(), @@ -2267,8 +2267,7 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname, RenameKind kin // No argument? Ask user through dialog. // FIXME UNICODE - FileDialog dlg(qt_("Choose a filename to save document as"), - LFUN_BUFFER_WRITE_AS); + FileDialog dlg(qt_("Choose a filename to save document as")); dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path)); dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path)); @@ -3473,7 +3472,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) case LFUN_FILE_INSERT_PLAINTEXT: case LFUN_FILE_INSERT_PLAINTEXT_PARA: { - bool const as_paragraph = (cmd.action() == LFUN_FILE_INSERT_PLAINTEXT_PARA); string const fname = to_utf8(cmd.argument()); if (!fname.empty() && !FileName::isAbsolute(fname)) { dr.setMessage(_("Absolute filename expected.")); @@ -3482,8 +3480,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) FileName filename(fname); if (fname.empty()) { - FileDialog dlg(qt_("Select file to insert"), (as_paragraph ? - LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT)); + FileDialog dlg(qt_("Select file to insert")); FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()), QStringList(qt_("All Files (*)"))); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index 6d9bdcac4c..63834eb6a0 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -261,10 +261,6 @@ public: virtual row_type row(idx_type) const { return 0; } /// cell index corresponding to row and column; virtual idx_type index(row_type row, col_type col) const; - /// any additional x-offset when drawing a cell? - virtual int cellXOffset(idx_type) const { return 0; } - /// any additional y-offset when drawing a cell? - virtual int cellYOffset(idx_type) const { return 0; } /// number of embedded cells virtual size_t nargs() const { return 0; } /// number of rows in gridlike structures diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 83e49c43b8..2b6b9a3a3d 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -1771,7 +1771,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c) // but suppress direct insertion of two spaces in a row // the still allows typing 'a' and deleting the 'a', but // it is better than nothing... - if (!cur.pos() != 0 || cur.prevAtom()->getChar() != ' ') { + if (cur.pos() == 0 || cur.prevAtom()->getChar() != ' ') { cur.insert(c); // FIXME: we have to enable full redraw here because of the // visual box corners that define the inset. If we know for diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 281ffc2971..d76a35379a 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -742,35 +742,15 @@ XHTMLStream & XHTMLStream::operator<<(html::EndTag const & etag) // curtag is now the one we actually want. os_ << curtag->writeEndTag(); tag_stack_.pop_back(); - + return *this; } // End code for XHTMLStream namespace { - -// convenience functions - -inline void openTag(XHTMLStream & xs, Layout const & lay) -{ - xs << html::StartTag(lay.htmltag(), lay.htmlattr()); -} - - -void openTag(XHTMLStream & xs, Layout const & lay, - ParagraphParameters const & params) -{ - // FIXME Are there other things we should handle here? - string const align = alignmentToCSS(params.align()); - if (align.empty()) { - openTag(xs, lay); - return; - } - string attrs = lay.htmlattr() + " style='text-align: " + align + ";'"; - xs << html::StartTag(lay.htmltag(), attrs); -} +// convenience functions inline void openParTag(XHTMLStream & xs, Layout const & lay, std::string parlabel) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 0676cad19b..bb74519f57 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -133,9 +133,6 @@ const char * const known_sans_fonts[] = { "avant", "berasans", "biolinum-type1", "cmbr", "cmss", "helvet", "iwona", "iwonac", "iwonal", "iwonalc", "kurier", "kurierc", "kurierl", "kurierlc", "lmss", "tgadventor", "tgheros", 0}; -const char * const known_kurier_fonts[] = { "kurier", "kurierl", -"kurier-condensed", "kurier-light-condensed", 0}; - const char * const known_typewriter_fonts[] = { "beramono", "cmtl", "cmtt", "courier", "lmtt", "luximono", "fourier", "lmodern", "mathpazo", "mathptmx", "newcent", "tgcursor", "txtt", 0}; -- 2.39.2