+2000-09-14 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/buffer.C (writeFile): try to fix the locale modified format
+ number to always be as we want it.
+
+ * src/WorkArea.C (work_area_handler): try to workaround the bugs
+ in XForms 0.89. C-space is now working again.
+
+ * src/Lsstream.h src/support/sstream.h: new files.
+
+ * also commented out all cases where strstream were used.
+
+ * src/Bullet.h (c_str): remove method.
+
+ * remove all stuff that is irrelevant when NEW_MENUBAR is defined
+
+ * a lot of files: get rid of "char const *" and "char *" is as
+ many places as possible. We only want to use them in interaction
+ with system of other libraries, not inside lyx.
+
+ * a lot of files: return const object is not of pod type. This
+ helps ensure that temporary objects is not modified. And fits well
+ with "programming by contract".
+
+ * configure.in: check for the locale header too
+
+ * Makefile.am (sourcedoc): new tag for generation of doc++
+ documentation
+
2000-09-14 Juergen Vigna <jug@sad.it>
* src/frontends/xforms/FormDocument.C (ComboInputCB): fixed the
@echo "*** distribution and refer to *you* in case of problem."
@echo "*** $(bindistfile) has been created."
+
+sourcedoc:
+ mkdir sourcedoc
+ cd sourcedoc
+ doc++ -p $(srcdir)/src/*.h
LYX_STD_COUNT
dnl we disable rtti for now
dnl LYX_CXX_RTTI
-AC_CHECK_HEADERS(ostream istream sstream)
+AC_CHECK_HEADERS(ostream istream sstream locale)
LYX_CXX_STL_MODERN_STREAMS
### We need a regex implementation, so we provide our own if none is found.
src/mathed/math_forms.C
src/mathed/math_panel.C
src/MenuBackend.C
-src/menus.C
src/minibuffer.C
src/PaperLayout.C
src/paragraph.C
stakk.push(bit);
}
///
- string pop(int * x, int * y) {
+ string const pop(int * x, int * y) {
BackStackItem bit = stakk.top();
*x = bit.x;
*y = bit.y;
///
void selectLastWord();
///
- char * nextWord(float & value);
+ string const nextWord(float & value);
///
void insertCorrectQuote();
///
/* these functions are for the spellchecker */
-char * BufferView::nextWord(float & value)
+string const BufferView::nextWord(float & value)
{
if (!available()) {
value = 1;
return 0;
}
- char * string = text->SelectNextWord(this, value);
-
- return string;
+ return text->SelectNextWord(this, value);
}
#include "intl.h"
#include "support/LAssert.h"
#include "frontends/Dialogs.h"
-#ifndef NEW_MENUBAR
-# include "menus.h"
-#endif
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
updateScrollbar();
}
bv_->text->first = screen_->TopCursorVisible(bv_->text);
-#ifdef NEW_MENUBAR
owner_->updateMenubar();
-#else
- owner_->getMenus()->showMenus();
-#endif
owner_->updateToolbar();
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
} else {
lyxerr[Debug::INFO] << " No Buffer!" << endl;
-#ifdef NEW_MENUBAR
owner_->updateMenubar();
-#else
- owner_->getMenus()->hideMenus();
-#endif
owner_->updateToolbar();
updateScrollbar();
workarea_->redraw();
///
BackStack backstack;
///
- int last_click_x, last_click_y;
+ int last_click_x;
+ ///
+ int last_click_y;
///
WorkArea * workarea_;
///
}
-bool operator == (const Bullet & b1, const Bullet & b2)
+bool operator==(const Bullet & b1, const Bullet & b2)
{
bool result = false;
}
-string Bullet::bulletSize(short int s)
+string const Bullet::bulletSize(short int s)
{
// use a parameter rather than hard code `size' in here
// in case some future function may want to retrieve
}
-string Bullet::bulletEntry(short int f, short int c)
+string const Bullet::bulletEntry(short int f, short int c)
{
// Despite how this may at first appear the static local variables
// are only initialized once..
///
string const & getText() const;
///
- char const * c_str() const;
- ///
- Bullet & operator = (Bullet const &);
+ Bullet & operator=(Bullet const &);
///
friend bool operator==(Bullet const &, Bullet const &);
- ///
- friend bool operator!=(Bullet const & b1, Bullet const & b2) {
- return !(b1 == b2);
- }
protected:
#ifdef ENABLE_ASSERTIONS
///
///
void generateText() const;
///
- static string bulletSize(short int);
+ static string const bulletSize(short int);
///
- static string bulletEntry(short int, short int);
+ static string const bulletEntry(short int, short int);
///
short font;
return *this;
}
+/*-----------------End Bullet Member Functions-----------------*/
inline
-char const * Bullet::c_str() const
+bool operator!=(Bullet const & b1, Bullet const & b2)
{
- return getText().c_str();
+ return !(b1 == b2);
}
-
-/*-----------------End Bullet Member Functions-----------------*/
-
///
extern
Bullet const ITEMIZE_DEFAULTS[];
}
-string FloatList::defaultPlacement(string const & t) const
+string const FloatList::defaultPlacement(string const & t) const
{
List::const_iterator cit = list.find(t);
if (cit != list.end())
///
void newFloat(Floating const & fl);
///
- string defaultPlacement(string const & t) const;
+ string const defaultPlacement(string const & t) const;
///
bool typeExist(string const & t) const;
///
using std::endl;
/// Load font close to this size
-string FontInfo::getFontname(int size)
+string const FontInfo::getFontname(int size)
{
if (!exist())
return string();
/// Build newly sized font string
-string FontInfo::resize(string const & font, int size) const
+string const FontInfo::resize(string const & font, int size) const
{
string ret(font);
// Find the position of the size spec
}
/// Get existing pattern
- string getPattern() const { return pattern; }
+ string const getPattern() const { return pattern; }
/// Set new pattern
void setPattern(string const & pat);
/** Return full name of font close to this size.
If impossible, result is the empty string */
- string getFontname(int size);
+ string const getFontname(int size);
private:
/// Font pattern (with wildcard for size)
string pattern;
void query();
/// Build newly sized font string
- string resize(string const &, int size) const;
+ string const resize(string const &, int size) const;
};
#endif
// Provide the literate documentclass by parsing the file.
-string ImportNoweb::documentclass()
+string const ImportNoweb::documentclass()
{
string result = "literate-article"; // Default
///
string file;
///
- string documentclass();
+ string const documentclass();
///
enum {
///
}
-string LColor::getGUIName(LColor::color c) const
+string const LColor::getGUIName(LColor::color c) const
{
InfoTab::const_iterator ici = infotab.find(c);
if (ici != infotab.end())
}
-string LColor::getX11Name(LColor::color c) const
+string const LColor::getX11Name(LColor::color c) const
{
InfoTab::const_iterator ici = infotab.find(c);
if (ici != infotab.end())
}
-string LColor::getLaTeXName(LColor::color c) const
+string const LColor::getLaTeXName(LColor::color c) const
{
InfoTab::const_iterator ici = infotab.find(c);
if (ici != infotab.end())
}
-string LColor::getLyXName(LColor::color c) const
+string const LColor::getLyXName(LColor::color c) const
{
InfoTab::const_iterator ici = infotab.find(c);
if (ici != infotab.end())
if (!compare_no_case((*ici).second.guiname, guiname))
return (*ici).first;
}
- return LColor::ignore;
+ return LColor::inherit;
}
///
bool setColor(string const & lyxname, string const & x11name);
/// Get GUI name of color
- string getGUIName(LColor::color c) const;
+ string const getGUIName(LColor::color c) const;
/// Get X11 name of color
- string getX11Name(LColor::color c) const;
+ string const getX11Name(LColor::color c) const;
/// Get LaTeX name of color
- string getLaTeXName(LColor::color c) const;
+ string const getLaTeXName(LColor::color c) const;
/// Get LyX name of color
- string getLyXName(LColor::color c) const;
+ string const getLyXName(LColor::color c) const;
///
LColor::color getFromGUIName(string const & guiname) const;
///
#include "DepTable.h"
#include <vector>
+#include "support/utility.hpp"
+
class MiniBuffer;
///
///
-class LaTeX {
+class LaTeX : public noncopyable {
public:
/** Return values from scanLogFile() and run() (to come)
/// The dependency file.
string depfile;
- /// unavail
- LaTeX(LaTeX const &);
- /// unavail
- LaTeX & operator= (LaTeX const &);
-
///
void deplog(DepTable & head);
array = false;
color = false;
graphics = false; // INSET_GRAPHICS: remove this when InsetFig is thrown.
- graphicx = false;
+ graphicx = false;
setspace = false;
makeidx = false;
verbatim = false;
NeedLyXMinipageIndent = false;
}
-void LaTeXFeatures::require(string const & name) {
+
+void LaTeXFeatures::require(string const & name)
+{
if (name == "array") {
array = true;
} else if (name == "color") {
}
}
-string LaTeXFeatures::getPackages()
+
+string const LaTeXFeatures::getPackages()
{
string packages;
LyXTextClass const & tclass =
+ params.graphicsDriver + "]{graphicx}\n";
}
- // INSET_GRAPHICS: remove this when InsetFig is thrown.
+ // INSET_GRAPHICS: remove this when InsetFig is thrown.
// graphics.sty
if (graphics && params.graphicsDriver != "none") {
if (params.graphicsDriver == "default")
packages += "\\doublespacing\n";
break;
case Spacing::Other:
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream value;
-#else
- char val[30];
- ostrstream value(val, 30);
-
-#endif
+//#else
+// char val[30];
+// ostrstream value(val, 30);
+//
+//#endif
value << params.spacing.getValue(); // setw?
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
packages += string("\\setstretch{")
+ value.str().c_str() + "}\n";
-#else
- value << '\0';
- packages += string("\\setstretch{")
- + value.str() + "}\n";
-#endif
+//#else
+// value << '\0';
+// packages += string("\\setstretch{")
+// + value.str() + "}\n";
+//#endif
break;
}
}
-string LaTeXFeatures::getMacros()
+string const LaTeXFeatures::getMacros()
{
string macros;
}
-string LaTeXFeatures::getTClassPreamble()
+string const LaTeXFeatures::getTClassPreamble()
{
// the text class specific preamble
LyXTextClass const & tclass =
}
-string LaTeXFeatures::getIncludedFiles()
+string const LaTeXFeatures::getIncludedFiles()
{
string sgmlpreamble;
FileMap::const_iterator end = IncludedFiles.end();
///
LaTeXFeatures(BufferParams const &, int n) ;
/// The packaes needed by the document
- string getPackages();
+ string const getPackages();
/// The macros definitions needed by the document
- string getMacros();
+ string const getMacros();
/// The definitions needed by the document's textclass
- string getTClassPreamble();
+ string const getTClassPreamble();
///
- string getIncludedFiles();
+ string const getIncludedFiles();
///
void showStruct();
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifndef LSSTREAM_H
+#define LSSTREAM_H
+
+#ifdef HAVE_SSTREAM
+#include <sstream>
+#else
+#include "support/sstream.h"
+#endif
+
+#endif
}
-string LyXAction::getApproxFuncName(string const & func) const
+string const LyXAction::getApproxFuncName(string const & func) const
{
int f = getApproxFunc(func);
// This will return empty string if f isn't an action.
}
-string LyXAction::getActionName(int action) const
+string const LyXAction::getActionName(int action) const
{
kb_action ac;
string arg;
// Returns one line help associated with a (pseudo)action, i.e. appends
// the argument of the action if necessary
-string LyXAction::helpText(int pseudoaction) const
+string const LyXAction::helpText(int pseudoaction) const
{
string help, arg;
kb_action action;
/** Returns an action name the most similar to a string.
Don't include arguments, they would be ignored. */
- string getApproxFuncName(string const & func) const;
+ string const getApproxFuncName(string const & func) const;
/// Returns a pseudo-action given an action and its argument.
int getPseudoAction(kb_action action, string const & arg) const;
bool isPseudoAction(int) const;
/// Return the name associated with command
- string getActionName(int action) const;
+ string const getActionName(int action) const;
/// Return one line help text associated with (pseudo)action
- string helpText(int action) const;
+ string const helpText(int action) const;
/// True if the command has `flag' set
bool funcHasFlag(kb_action action, func_attrib flag) const;
#include "buffer.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
-#ifdef NEW_MENUBAR
-# include "frontends/Menubar.h"
-# include "MenuBackend.h"
-#else
-# include "menus.h"
-#endif
+#include "frontends/Menubar.h"
+#include "MenuBackend.h"
#include "ToolbarDefaults.h"
#include "lyx_gui_misc.h" // [update,Close]AllBufferRelatedDialogs
#include "bufferview_funcs.h" // CurrentState()
LyXView::~LyXView()
{
-#ifdef NEW_MENUBAR
delete menubar;
-#else
- delete menus;
-#endif
delete toolbar;
delete bufferview;
delete minibuffer;
}
-#ifdef NEW_MENUBAR
Menubar * LyXView::getMenubar() const
{
return menubar;
menubar->set("main");
}
-#else
-Menus * LyXView::getMenus() const
-{
- return menus;
-}
-#endif
-
Intl * LyXView::getIntl() const
{
}
-void LyXView::show(int place, int border, char const * title)
+void LyXView::show(int place, int border, string const & title)
{
- fl_show_form(form_, place, border, title);
+ fl_show_form(form_, place, border, title.c_str());
minibuffer->Init();
InitLyXLookup(fl_display, form_->window);
}
//
// THE MENUBAR
//
-#ifdef NEW_MENUBAR
menubar = new Menubar(this, menubackend);
-#else
- menus = new Menus(this, air);
-#endif
//
// TOOLBAR
invalidateLayoutChoice();
updateLayoutChoice();
UpdateDocumentClassChoice();
-#ifdef NEW_MENUBAR
updateMenubar();
-#endif
// Start autosave timer
if (lyxrc.autosave) {
#include FORMS_H_LOCATION
+#include "LString.h"
#include "Timeout.h"
#include "support/utility.hpp"
-// uncomment this line to try out the new menus
-#define NEW_MENUBAR 1
class LyXFunc;
class Toolbar;
class MiniBuffer;
class Intl;
class Buffer;
-#ifdef NEW_MENUBAR
class Menubar;
-#else
-class Menus;
-#endif
class BufferView;
class Dialogs;
void setPosition(int, int);
/// Show the main form.
- void show(int, int, char const * t = "LyX");
+ void show(int, int, string const & t = string("LyX"));
/// init (should probably be removed later) (Lgb)
void init();
/// return a pointer to the minibuffer
MiniBuffer * getMiniBuffer() const;
-#ifdef NEW_MENUBAR
///
Menubar * getMenubar() const;
///
void updateMenubar();
-#else
- ///
- Menus * getMenus() const;
-#endif
+
///
Intl * getIntl() const;
Toolbar * toolbar;
///
MiniBuffer * minibuffer;
-#ifdef NEW_MENUBAR
///
Menubar * menubar;
-#else
- ///
- Menus * menus;
-#endif
///
Intl * intl;
///
LaTeXLog.C \
Literate.C \
Literate.h \
+ Lsstream.h \
LyXAction.C \
LyXAction.h \
LyXSendto.C \
lyxvc.C \
lyxvc.h \
main.C \
- menus.C \
- menus.h \
minibuffer.C \
minibuffer.h \
nt_defines.h \
spellchecker.C \
spellchecker.h \
stl_string_fwd.h \
- table.C \
- table.h \
tabular.C \
tabular.h \
tex-accent.C \
string const & command = string(),
bool optional = false);
/// The label of a given menuitem
- string label() const { return token(label_, '|', 0); }
+ string const label() const { return token(label_, '|', 0); }
///
- string shortcut() const { return token(label_, '|', 1); }
+ string const shortcut() const { return token(label_, '|', 1); }
/// The kind of entry
Kind kind() const { return kind_; }
/// the action (if relevant)
/// Draw a string at position x, y (y is the baseline)
virtual PainterBase & text(int x, int y,
- string const &str, LyXFont const & f) = 0;
+ string const & str, LyXFont const & f) = 0;
/** Draw a string at position x, y (y is the baseline)
This is just for fast drawing */
#pragma implementation
#endif
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
using std::istringstream;
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#include "Spacing.h"
#include "LString.h"
}
-void Spacing::set(Spacing::Space sp, char const * val)
+void Spacing::set(Spacing::Space sp, string const & val)
{
float fval;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
istringstream istr(val);
-#else
- istrstream istr(val);
-#endif
+//#else
+// istrstream istr(val.c_str());
+//#endif
istr >> fval;
set(sp, fval);
}
}
-string Spacing::writeEnvirBegin() const
+string const Spacing::writeEnvirBegin() const
{
switch(space) {
case Default: break; // do nothing
case Double:
return "\\begin{doublespace}";
case Other:
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
+ {
ostringstream ost;
ost << "\\begin{spacing}{"
<< getValue() << "}";
return ost.str().c_str();
-#else
- {
- char tmp[512];
- ostrstream ost(tmp, 512);
- ost << "\\begin{spacing}{"
- << getValue() << "}" << '\0';
- return ost.str();
- }
-#endif
+ }
+//#else
+// {
+// char tmp[512];
+// ostrstream ost(tmp, 512);
+// ost << "\\begin{spacing}{"
+// << getValue() << "}\0";
+// return ost.str();
+// }
+//#endif
}
return string();
}
-string Spacing::writeEnvirEnd() const
+string const Spacing::writeEnvirEnd() const
{
switch(space) {
case Default: break; // do nothing
///
void set(Spacing::Space sp, float val = 1.0);
///
- void set(Spacing::Space sp, char const * val) ;
+ void set(Spacing::Space sp, string const & val) ;
///
void writeFile(std::ostream &, bool para = false) const;
///
- string writeEnvirBegin() const;
+ string const writeEnvirBegin() const;
///
- string writeEnvirEnd() const;
- ///
- friend bool operator==(Spacing const & a, Spacing const & b) {
- return a.space == b.space && a.getValue() == b.getValue();
- }
- ///
- friend bool operator!=(Spacing const & a, Spacing const & b) {
- return !(a == b);
- }
+ string const writeEnvirEnd() const;
private:
///
Space space;
///
float value;
};
+
+
+///
+inline
+bool operator==(Spacing const & a, Spacing const & b)
+{
+ return a.getSpace() == b.getSpace()
+ && a.getValue() == b.getValue();
+}
+
+///
+inline
+bool operator!=(Spacing const & a, Spacing const & b)
+{
+ return !(a == b);
+}
#endif
}
-string Variables::get(string const & var) const
+string const Variables::get(string const & var) const
{
Vars::const_iterator cit = vars_.find(var);
if (cit != vars_.end())
}
-string Variables::expand(string const & s) const
+string const Variables::expand(string const & s) const
{
string str(s);
LRegex reg("\\$\\{\\(.*\\)\\}");
///
void set(string const &, string const &);
///
- string get(string const &) const;
+ string const get(string const &) const;
///
bool isset(string const & var) const;
///
- string expand(string const &) const;
+ string const expand(string const &) const;
private:
///
typedef std::map<string, string> Vars;
XSync(fl_get_display(), 0);
}
+
extern "C" {
// Just a bunch of C wrappers around static members of WorkArea
void C_WorkArea_scroll_cb(FL_OBJECT * ob, long buf)
width - 15 - 2 * bw, // scrollbarwidth
height - 2 * bw, "",
C_WorkArea_work_area_handler);
- //obj->wantkey = FL_KEY_TAB;
obj->wantkey = FL_KEY_ALL;
obj->u_vdata = this; /* This is how we pass the WorkArea
- to the work_area_handler. */
+ to the work_area_handler. */
fl_set_object_boxtype(obj,FL_DOWN_BOX);
fl_set_object_resize(obj, FL_RESIZE_ALL);
fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity);
waitForX();
}
+
bool Lgb_bug_find_hack = false;
int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
}
KeySym ret_key = keysym;
#else
- // Ok, this is a bit simplistic...seems that the rules
- // need to be a bit more...
- if (!key) break;
- KeySym ret_key = (keysym ? keysym : key);
+ // Note that we need this handling because of a bug
+ // in XForms 0.89, if this bug is resolved in the way I hope
+ // we can just use the keysym directly with out looking
+ // at key at all. (Lgb)
+ KeySym ret_key = 0;
+ if (!key) {
+ // We migth have to add more keysyms here also,
+ // we will do that as the issues arise. (Lgb)
+ if (keysym == XK_space)
+ ret_key = keysym;
+ else
+ break;
+ } else {
+ ret_key = (keysym ? keysym : key);
+ }
+
#endif
unsigned int ret_state = xke->state;
-
+
+ // If you have a better way to handle "wild-output" of
+ // characters after the key has been released than the one
+ // below, please contact me. (Lgb)
static Time last_time_pressed = 0;
static unsigned int last_key_pressed = 0;
static unsigned int last_state_pressed = 0;
- //lyxerr << "Workarea Diff: " << xke->time - last_time_pressed
- // << endl;
- if (xke->time - last_time_pressed < 40 // should perhaps be tunable
+ lyxerr[Debug::KEY] << "Workarea Diff: "
+ << xke->time - last_time_pressed
+ << endl;
+ if (xke->time - last_time_pressed < 35 // should perhaps be tunable
&& xke->state == last_state_pressed
&& xke->keycode == last_key_pressed) {
lyxerr[Debug::KEY]
clipboard_read = true;
return 0;
}
-}
+} // extern "C"
+
-string WorkArea::getClipboard() const
+string const WorkArea::getClipboard() const
{
clipboard_read = false;
return fl_get_scrollbar_value(scrollbar);
}
///
- std::pair<float, float> getScrollbarBounds() const {
+ std::pair<float, float> const getScrollbarBounds() const {
std::pair<float, float> p;
fl_get_scrollbar_bounds(scrollbar, &p.first, &p.second);
return p;
/// xforms callback
static void scroll_cb(FL_OBJECT *, long);
///
- string getClipboard() const;
+ string const getClipboard() const;
///
void putClipboard(string const &) const;
///
#include <algorithm>
+#ifdef HAVE_LOCALE
+#include <locale>
+#endif
+
#ifdef __GNUG__
#pragma implementation "buffer.h"
#endif
using std::vector;
using std::max;
using std::set;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
using std::istringstream;
-#endif
+//#endif
// all these externs should eventually be removed.
extern BufferList bufferlist;
}
-string Buffer::getLatexName(bool no_path) const
+string const Buffer::getLatexName(bool no_path) const
{
if (no_path)
return OnlyFilename(ChangeExtension(MakeLatexName(filename),
old_float += "\n\\end_inset\n";
//lyxerr << "float body: " << old_float << endl;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
istringstream istr(old_float);
-#else
- istrstream istr(old_float.c_str());
-#endif
+//#else
+// istrstream istr(old_float.c_str());
+//#endif
LyXLex nylex(0, 0);
nylex.setStream(istr);
fname);
return false;
}
+
+#ifdef HAVE_LOCALE
+ // Use the standard "C" locale for file output.
+ ofs.imbue(locale::classic());
+#endif
+
// The top of the file should not be written by params.
// write out a comment in the top of the file
<< " created this file. For more info see http://www.lyx.org/\n";
ofs.setf(ios::showpoint|ios::fixed);
ofs.precision(2);
+#ifndef HAVE_LOCALE
+ char dummy_format[512];
+ sprintf(dummy_format, "%.2f", LYX_FORMAT);
+ ofs << "\\lyxformat " << dummy_format << "\n";
+#else
ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n";
-
+#endif
// now write out the buffer paramters.
params.writeFile(ofs);
c = par->GetChar(i);
if (c == LyXParagraph::META_INSET) {
if ((inset = par->GetInset(i))) {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
inset->Ascii(this, ost);
h += ost.str().length();
-#else
- ostrstream ost;
- inset->Ascii(this, ost);
- ost << '\0';
- char * tmp = ost.str();
- string tstr(tmp);
- h += tstr.length();
- delete [] tmp;
-#endif
+//#else
+// ostrstream ost;
+// inset->Ascii(this, ost);
+// ost << '\0';
+// char * tmp = ost.str();
+// string tstr(tmp);
+// h += tstr.length();
+// delete [] tmp;
+//#endif
}
} else if (c == LyXParagraph::META_NEWLINE) {
if (clen[j] < h)
{
bool was_title = false;
bool already_title = false;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ftnote;
-#else
- char * tmpholder = 0;
-#endif
+//#else
+// char * tmpholder = 0;
+//#endif
TexRow ft_texrow;
int ftcount = 0;
// if only_body
while (par != endpar) {
-#ifndef HAVE_SSTREAM
- ostrstream ftnote;
- if (tmpholder) {
- ftnote << tmpholder;
- delete [] tmpholder;
- tmpholder = 0;
- }
-#endif
+//#ifndef HAVE_SSTREAM
+// ostrstream ftnote;
+// if (tmpholder) {
+// ftnote << tmpholder;
+// delete [] tmpholder;
+// tmpholder = 0;
+// }
+//#endif
#ifndef NEW_INSETS
if (par->IsDummy())
lyxerr[Debug::LATEX] << "Error in latexParagraphs."
}
ofs << ftnote.str();
texrow += ft_texrow;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
// The extra .c_str() is needed when we use
// lyxstring instead of the STL string class.
ftnote.str(string().c_str());
-#else
- delete [] ftnote.str();
-#endif
+//#else
+// delete [] ftnote.str();
+//#endif
ft_texrow.reset();
ftcount = 0;
}
-#ifndef HAVE_SSTREAM
- else {
- // I hate strstreams
- tmpholder = ftnote.str();
- }
-#endif
+//#ifndef HAVE_SSTREAM
+// else {
+// // I hate strstreams
+// tmpholder = ftnote.str();
+// }
+//#endif
}
-#ifndef HAVE_SSTREAM
- delete [] tmpholder;
-#endif
+//#ifndef HAVE_SSTREAM
+// delete [] tmpholder;
+//#endif
// It might be that we only have a title in this document
if (was_title && !already_title) {
ofs << "\\maketitle\n";
if (par->layout != textclasslist
.NumberOfLayout(params.textclass,
"Caption").second) {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
-#else
- ostrstream ost;
-#endif
+//#else
+// ostrstream ost;
+//#endif
SimpleDocBookOnePar(ost, extra_par, par,
desc_on, depth + 2);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
tmp_par += ost.str().c_str();
-#else
- ost << '\0';
- char * ctmp = ost.str();
- tmp_par += ctmp;
- delete [] ctmp;
-#endif
+//#else
+// ost << '\0';
+// char * ctmp = ost.str();
+// tmp_par += ctmp;
+// delete [] ctmp;
+//#endif
}
tmp_par = frontStrip(strip(tmp_par));
// push a tag in a style stack
-void Buffer::push_tag(ostream & os, char const * tag,
+void Buffer::push_tag(ostream & os, string const & tag,
int & pos, char stack[5][3])
{
+#warning Use a real stack! (Lgb)
// pop all previous tags
for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";
// add new tag
- sprintf(stack[++pos], "%s", tag);
+ sprintf(stack[++pos], "%s", tag.c_str());
// push all tags
for (int i = 0; i <= pos; ++i)
}
-void Buffer::pop_tag(ostream & os, char const * tag,
+void Buffer::pop_tag(ostream & os, string const & tag,
int & pos, char stack[5][3])
{
- int j;
-
+#warning Use a real stack! (Lgb)
// pop all tags till specified one
- for (j = pos; (j >= 0) && (strcmp(stack[j], tag)); --j)
+ for (int j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
os << "</" << stack[j] << ">";
// closes the tag
os << "</" << tag << ">";
// push all tags, but the specified one
- for (j = j + 1; j <= pos; ++j) {
+ for (int j = j + 1; j <= pos; ++j) {
os << "<" << stack[j] << ">";
strcpy(stack[j-1], stack[j]);
}
// Print an error message.
void Buffer::LinuxDocError(LyXParagraph * par, int pos,
- char const * message)
+ string const & message)
{
// insert an error marker in text
InsetError * new_inset = new InsetError(message);
if (c == LyXParagraph::META_INSET) {
Inset * inset = par->GetInset(i);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
inset->DocBook(this, ost);
string tmp_out = ost.str().c_str();
-#else
- ostrstream ost;
- inset->DocBook(this, ost);
- ost << '\0';
- char * ctmp = ost.str();
- string tmp_out(ctmp);
- delete [] ctmp;
-#endif
+//#else
+// ostrstream ost;
+// inset->DocBook(this, ost);
+// ost << '\0';
+// char * ctmp = ost.str();
+// string tmp_out(ctmp);
+// delete [] ctmp;
+//#endif
//
// This code needs some explanation:
// Two insets are treated specially
// This function should be in Buffer because it's a buffer's property (ale)
-string Buffer::getIncludeonlyList(char delim)
+string const Buffer::getIncludeonlyList(char delim)
{
string lst;
for (inset_iterator it = inset_iterator_begin();
}
-vector<string> Buffer::getLabelList()
+vector<string> const Buffer::getLabelList()
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990407]
}
-vector<vector<Buffer::TocItem> > Buffer::getTocList()
+vector<vector<Buffer::TocItem> > const Buffer::getTocList()
{
vector<vector<TocItem> > l(4);
LyXParagraph * par = paragraph;
return l;
}
+
// This is also a buffer property (ale)
-vector<pair<string,string> > Buffer::getBibkeyList()
+vector<pair<string,string> > const Buffer::getBibkeyList()
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990412]
bool nice, bool only_body = false);
/// returns the main language for the buffer (document)
- string GetLanguage() const {
+ string const GetLanguage() const {
return params.language;
}
/** A transformed version of the file name, adequate for LaTeX
The path is stripped if no_path is true (default)
*/
- string getLatexName(bool no_path = true) const;
+ string const getLatexName(bool no_path = true) const;
/// Change name of buffer. Updates "read-only" flag.
void fileName(string const & newfile);
void validate(LaTeXFeatures &) const;
///
- string getIncludeonlyList(char delim = ',');
+ string const getIncludeonlyList(char delim = ',');
///
- std::vector<std::pair<string,string> > getBibkeyList();
+ std::vector<std::pair<string,string> > const getBibkeyList();
///
struct TocItem {
///
TOC_LOA
};
///
- std::vector<std::vector<TocItem> > getTocList();
+ std::vector<std::vector<TocItem> > const getTocList();
///
- std::vector<string> getLabelList();
+ std::vector<string> const getLabelList();
/** This will clearly have to change later. Later we can have more
than one user per buffer. */
void sgmlCloseTag(std::ostream & os, int depth,
string const & latexname) const;
///
- void LinuxDocError(LyXParagraph * par, int pos, char const * message);
+ void LinuxDocError(LyXParagraph * par, int pos,
+ string const & message);
///
void SimpleLinuxDocOnePar(std::ostream & os, LyXParagraph * par,
int desc_on, int const depth);
int const depth);
/// LinuxDoc.
- void push_tag(std::ostream & os, char const * tag,
+ void push_tag(std::ostream & os, string const & tag,
int & pos, char stack[5][3]);
/// LinuxDoc.
- void pop_tag(std::ostream & os, char const * tag,
+ void pop_tag(std::ostream & os, string const & tag,
int & pos, char stack[5][3]);
/// is save needed
friend
bool operator==(inset_iterator const & iter1,
inset_iterator const & iter2);
- ///
- friend
- bool operator!=(inset_iterator const & iter1,
- inset_iterator const & iter2);
+ //
+ //friend
+ //bool operator!=(inset_iterator const & iter1,
+ // inset_iterator const & iter2);
private:
///
void SetParagraph();
}
-vector<string> BufferList::getFileNames() const
+vector<string> const BufferList::getFileNames() const
{
vector<string> nvec;
for(BufferStorage::const_iterator cit = bstore.begin();
// no template, start with empty buffer
b->paragraph = new LyXParagraph;
}
- }
- else { // start with empty buffer
+ } else { // start with empty buffer
b->paragraph = new LyXParagraph;
}
-#warning Why mark a new document dirty? I deactivate this (Jug)
if (!lyxrc.new_ask_filename) {
-// b->markDirty();
if (!isNamed)
b->setUnnamed();
}
/// Make a new file (buffer) using a template
Buffer * newFile(string const &, string, bool isNamed=false);
/// returns a vector with all the buffers filenames
- std::vector<string> getFileNames() const;
+ std::vector<string> const getFileNames() const;
///
int unlockInset(UpdatableInset *);
else {
os << "\\bulletLaTeX " << i
<< "\n\t"
- << user_defined_bullets[i].c_str()
+ << user_defined_bullets[i].getText().c_str()
<< "\n\\end_bullet\n";
}
}
// Returns the current font and depth as a message.
-string CurrentState(BufferView * bv)
+string const CurrentState(BufferView * bv)
{
string state;
if (bv->available()) {
///
extern void FontSize(BufferView *, string const &);
/// Returns the current font and depth as a message.
-extern string CurrentState(BufferView *);
+extern string const CurrentState(BufferView *);
///
extern void ToggleAndShow(BufferView *, LyXFont const &);
#endif
fl_set_button(fd_form_bullet->radio_bullet_depth_1, 1);
fl_set_input(fd_form_bullet->input_bullet_latex,
current_view->buffer()
- ->params.user_defined_bullets[0].c_str());
+ ->params.user_defined_bullets[0].getText().c_str());
fl_set_choice(fd_form_bullet->choice_bullet_size,
current_view->buffer()
->params.user_defined_bullets[0].getSize() + 2);
// convert from 1-6 range to -1-4
param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
fl_set_input(fd_form_bullet->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].c_str());
+ param.temp_bullets[current_bullet_depth].getText().c_str());
}
default:
current_bullet_depth = data;
fl_set_input(fd_form_bullet->input_bullet_latex,
- param.temp_bullets[data].c_str());
+ param.temp_bullets[data].getText().c_str());
fl_set_choice(fd_form_bullet->choice_bullet_size,
param.temp_bullets[data].getSize() + 2);
}
param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
fl_set_input(fd_form_bullet->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].c_str());
+ param.temp_bullets[current_bullet_depth].getText().c_str());
}
}
-pair<bool, int> CharacterSet::encodeString(string const & str) const
+pair<bool, int> const CharacterSet::encodeString(string const & str) const
{
lyxerr[Debug::KBMAP] << "Checking if we know [" << str << "]" << endl;
bool ret = false;
///
string const & getName() const;
///
- std::pair<bool, int> encodeString(string const &) const;
+ std::pair<bool, int> const encodeString(string const &) const;
private:
///
string name_;
}
-void Combox::addline(char const* text)
+void Combox::addline(string const & text)
{
if (!browser) return;
- fl_add_browser_line(browser, text);
+ fl_add_browser_line(browser, text.c_str());
// By default the first item is selected
if (!sel) {
sel = 1;
if (type == FL_COMBOX_INPUT)
- fl_set_input(label, text);
+ fl_set_input(label, text.c_str());
else
- fl_set_object_label(label, text);
+ fl_set_object_label(label, text.c_str());
}
is_empty = false;
}
-bool Combox::select_text(char const* t)
+bool Combox::select_text(string const & t)
{
- if (!browser || !t) return false;
- for (int i = 1; i <= fl_get_browser_maxline(browser); ++i) {
- if (!strcmp(t, fl_get_browser_line(browser, i))) {
+ if (!browser || t.empty()) return false;
+ int const maxline = fl_get_browser_maxline(browser);
+
+ for (int i = 1; i <= maxline; ++i) {
+ if (t == fl_get_browser_line(browser, i)) {
select(i);
return true;
}
void Combox::select(int i)
{
if (!browser || !button) return;
- if (i>0 && i<= fl_get_browser_maxline(browser)) sel = i;
+ if (i > 0 && i <= fl_get_browser_maxline(browser)) sel = i;
fl_deactivate_object(button);
if (type == FL_COMBOX_INPUT)
void Combox::add(int x, int y, int w, int hmin, int hmax)
{
- FL_OBJECT *obj;
+ FL_OBJECT * obj;
switch(type) {
case FL_COMBOX_DROPLIST:
if (label) fl_deactivate_object(label);
}
-void Combox::input_cb(FL_OBJECT *ob, long)
+void Combox::input_cb(FL_OBJECT * ob, long)
{
Combox * combo = static_cast<Combox*>(ob->u_vdata);
#include FORMS_H_LOCATION
#include <cstdlib>
+#include "LString.h"
///
enum combox_type {
void add(int x, int y, int w, int hmin, int hmax);
/// Add lines. Same as for fl_browser object
- void addline(char const *);
+ void addline(string const &);
/// Add lines. Same as for fl_browser object
- void addto(char const *);
+ void addto(string const &);
/// Returns the selected item
int get();
/// Returns a pointer to the selected line of text
- char const * getline();
+ string const getline();
/// Select an arbitrary item
void select(int);
///
- bool select_text(char const *);
+ bool select_text(string const &);
/// Clear all the list
void clear();
///
void deactivate();
///
- void shortcut(char const *, int);
+ void shortcut(string const &, int);
///
void Redraw();
///
//----------------- Inline methods ---------------------------
inline
-void Combox::addto(char const * text)
+void Combox::addto(string const & text)
{
if (browser) {
- fl_addto_browser(browser, text);
+ fl_addto_browser(browser, text.c_str());
is_empty = false;
}
}
inline
-void Combox::shortcut(char const * s, int i)
+void Combox::shortcut(string const & s, int i)
{
if (button)
- fl_set_object_shortcut(button, s, i);
+ fl_set_object_shortcut(button, s.c_str(), i);
}
inline
-char const * Combox::getline()
+string const Combox::getline()
{
if (type == FL_COMBOX_INPUT)
return fl_get_input(label);
string Converter::latex_command;
inline
-string add_options(string const & command, string const & options)
+string const add_options(string const & command, string const & options)
{
string head;
string tail = split(command, head, ' ');
}
-string Converter::dvi_papersize(Buffer * buffer)
+string const Converter::dvi_papersize(Buffer const * buffer)
{
char real_papersize = buffer->params.papersize;
if (real_papersize == BufferParams::PAPER_DEFAULT)
}
-string Converter::dvips_options(Buffer * buffer)
+string const Converter::dvips_options(Buffer const * buffer)
{
string result;
if (buffer->params.use_geometry
bool Convert(Buffer * buffer, string const & from_file,
string const & to_file, string const & using_format,
string * view_file = 0);
+ ///
static
string const SplitFormat(string const & str, string & format);
///
static
- string dvi_papersize(Buffer * buffer);
+ string const dvi_papersize(Buffer const * buffer);
///
static
- string dvips_options(Buffer * buffer);
+ string const dvips_options(Buffer const * buffer);
private:
///
static
#include <cstring>
#include <map>
#include <algorithm>
+
using std::map;
using std::sort;
// GetDirectory: gets last dialog directory
-string LyXFileDlg::GetDirectory() const
+string const LyXFileDlg::GetDirectory() const
{
if (!pszDirectory.empty())
return pszDirectory;
// Select: launches dialog and returns selected file
-string LyXFileDlg::Select(string const & title, string const & path,
+string const LyXFileDlg::Select(string const & title, string const & path,
string const & mask, string const & suggested)
{
// handles new mask and path
void SetButton(int iIndex, string const & pszName = string(),
string const & pszPath = string());
/// gets last dialog directory
- string GetDirectory() const;
+ string const GetDirectory() const;
/// launches dialog and returns selected file
- string Select(string const & pszTitle = string(),
+ string const Select(string const & pszTitle = string(),
string const & pszPath = string(),
string const & pszMask = string(),
string const & pszSuggested = string());
}
+//int lyxfont::width(wstring const & s, int n, LyXFont const & f)
int lyxfont::width(XChar2b const * s, int n, LyXFont const & f)
{
if (!lyxrc.use_gui)
}
}
-int lyxfont::XTextWidth(LyXFont const & f, char * str, int count)
+int lyxfont::XTextWidth(LyXFont const & f, char const * str, int count)
{
return ::XTextWidth(getXFontstruct(f), str, count);
}
-int lyxfont::XTextWidth16(LyXFont const & f, XChar2b * str, int count)
+int lyxfont::XTextWidth16(LyXFont const & f, XChar2b const * str, int count)
{
return ::XTextWidth16(getXFontstruct(f), str, count);
}
int signedWidth(string const & s, LyXFont const & f);
///
static
- int XTextWidth(LyXFont const & f, char * str, int count);
+ int XTextWidth(LyXFont const & f, char const * str, int count);
///
static
int width(XChar2b const * s, int n, LyXFont const & f);
///
static
- int XTextWidth16(LyXFont const & f, XChar2b * str, int count);
+ int XTextWidth16(LyXFont const & f, XChar2b const * str, int count);
///
static
void XSetFont(Display * display, GC gc, LyXFont const & f);
*
* LyX, The Document Processor
*
- * Copyright (C) 2000 The LyX Team.
+ * Copyright 2000 The LyX Team.
*
* @author Jürgen Vigna
*
C_GENERICCB(FormDocument, InputBulletLaTeXCB)
C_GENERICCB(FormDocument, ChoiceBulletSizeCB)
+
FormDocument::FormDocument(LyXView * lv, Dialogs * d)
: dialog_(0), paper_(0), class_(0), language_(0), options_(0),
bullets_(0), lv_(lv), d_(d), u_(0), h_(0),
current_bullet_panel = 0;
}
+
FormDocument::~FormDocument()
{
free();
delete bc_;
}
+
void FormDocument::build()
{
int n;
}
}
+
void FormDocument::show()
{
if (!dialog_)
}
}
+
void FormDocument::hide()
{
if (dialog_->form->visible) {
}
}
+
void FormDocument::apply()
{
if (!lv_->view()->available() || !dialog_)
return;
- bool
- redo;
-
- redo = class_apply();
+ bool redo = class_apply();
paper_apply();
redo = language_apply() || redo;
redo = options_apply() || redo;
return redo;
}
+
void FormDocument::paper_apply()
{
- BufferParams
- ¶ms = lv_->buffer()->params;
+ BufferParams & params = lv_->buffer()->params;
params.papersize2 = fl_get_choice(paper_->choice_papersize2)-1;
params.paperpackage = fl_get_choice(paper_->choice_paperpackage)-1;
lv_->buffer()->setPaperStuff();
}
+
bool FormDocument::language_apply()
{
- BufferParams
- ¶ms = lv_->buffer()->params;
- InsetQuotes::quote_language
- lga = InsetQuotes::EnglishQ;
+ BufferParams & params = lv_->buffer()->params;
+ InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
bool redo = false;
switch(fl_get_choice(language_->choice_quotes_language) - 1) {
return redo;
}
+
bool FormDocument::options_apply()
{
- BufferParams
- ¶ms = lv_->buffer()->params;
- bool
- redo = false;
+ BufferParams & params = lv_->buffer()->params;
+ bool redo = false;
params.graphicsDriver =
fl_get_choice_text(options_->choice_postscript_driver);
return redo;
}
+
void FormDocument::bullets_apply()
{
/* update the bullet settings */
param.user_defined_bullets[3] = param.temp_bullets[3];
}
+
void FormDocument::cancel()
{
// this avoids confusion when reopening
param.temp_bullets[3] = param.user_defined_bullets[3];
}
+
void FormDocument::update()
{
if (!dialog_)
checkReadOnly();
- BufferParams
- const & params = lv_->buffer()->params;
+ BufferParams const & params = lv_->buffer()->params;
class_update(params);
paper_update(params);
bullets_update(params);
}
+
void FormDocument::class_update(BufferParams const & params)
{
if (!class_)
return;
- LyXTextClass
- const & tclass = textclasslist.TextClass(params.textclass);
+
+ LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
#ifdef USE_CLASS_COMBO
combo_doc_class->select_text(
fl_set_input(class_->input_doc_extra, "");
}
+
void FormDocument::language_update(BufferParams const & params)
{
if (!language_)
fl_set_button(language_->radio_double, 1);
}
+
void FormDocument::options_update(BufferParams const & params)
{
if (!options_)
fl_set_input(options_->input_float_placement, "");
}
+
void FormDocument::paper_update(BufferParams const & params)
{
if (!paper_)
fl_set_focus_object(paper_->form, paper_->choice_papersize2);
}
+
void FormDocument::bullets_update(BufferParams const & params)
{
if (!bullets_ || ((XpmVersion<4) || (XpmVersion==4 && XpmRevision<7)))
fl_set_button(bullets_->radio_bullet_depth_1, 1);
fl_set_input(bullets_->input_bullet_latex,
- params.user_defined_bullets[0].c_str());
+ params.user_defined_bullets[0].getText().c_str());
fl_set_choice(bullets_->choice_bullet_size,
params.user_defined_bullets[0].getSize() + 2);
}
+
void FormDocument::free()
{
if (dialog_) {
}
}
+
int FormDocument::WMHideCB(FL_FORM * form, void *)
{
// Ensure that the signals (u and h) are disconnected even if the
// window manager is used to close the popup.
- FormDocument * pre = (FormDocument*)form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(form->u_vdata);
pre->hide();
pre->bc_->hide();
return FL_CANCEL;
}
+
void FormDocument::OKCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->apply();
pre->hide();
pre->bc_->ok();
}
+
void FormDocument::ApplyCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->apply();
pre->bc_->apply();
}
+
void FormDocument::CancelCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->cancel();
pre->hide();
pre->bc_->cancel();
}
+
void FormDocument::RestoreCB(FL_OBJECT * ob, long)
{
FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->bc_->undoAll();
}
+
void FormDocument::InputCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->bc_->valid(pre->CheckDocumentInput(ob,0));
}
+
void FormDocument::ComboInputCB(int, void * v, Combox * combox)
{
FormDocument * pre = static_cast<FormDocument*>(v);
pre->bc_->valid(pre->CheckDocumentInput(0,0));
}
+
void FormDocument::ChoiceClassCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->CheckChoiceClass(ob,0);
pre->bc_->valid(pre->CheckDocumentInput(ob,0));
}
+
void FormDocument::checkReadOnly()
{
if (bc_->readOnly(lv_->buffer()->isReadonly())) {
}
}
+
void FormDocument::checkMarginValues()
{
- int allEmpty;
-
- allEmpty = (!strlen(fl_get_input(paper_->input_top_margin)) &&
+ int const allEmpty = (!strlen(fl_get_input(paper_->input_top_margin)) &&
!strlen(fl_get_input(paper_->input_bottom_margin)) &&
!strlen(fl_get_input(paper_->input_left_margin)) &&
!strlen(fl_get_input(paper_->input_right_margin)) &&
return ok;
}
+
void FormDocument::ChoiceBulletSizeCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->ChoiceBulletSize(ob,0);
pre->bc_->valid(pre->CheckDocumentInput(ob,0));
}
+
void FormDocument::ChoiceBulletSize(FL_OBJECT * ob, long /*data*/ )
{
BufferParams & param = lv_->buffer()->params;
// convert from 1-6 range to -1-4
param.temp_bullets[current_bullet_depth].setSize(fl_get_choice(ob) - 2);
fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].c_str());
+ param.temp_bullets[current_bullet_depth].getText().c_str());
}
+
void FormDocument::InputBulletLaTeXCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->InputBulletLaTeX(ob,0);
pre->bc_->valid(pre->CheckDocumentInput(ob,0));
}
+
void FormDocument::InputBulletLaTeX(FL_OBJECT *, long)
{
BufferParams & param = lv_->buffer()->params;
setText(fl_get_input(bullets_->input_bullet_latex));
}
+
void FormDocument::BulletDepthCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->BulletDepth(ob,0);
}
+
void FormDocument::BulletDepth(FL_OBJECT * ob, long data)
{
/* Should I do the following: */
default:
current_bullet_depth = data;
fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[data].c_str());
+ param.temp_bullets[data].getText().c_str());
fl_set_choice(bullets_->choice_bullet_size,
param.temp_bullets[data].getSize() + 2);
}
}
+
void FormDocument::BulletPanelCB(FL_OBJECT * ob, long data)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->BulletPanel(ob,data);
}
+
void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, long data)
{
/* Here we have to change the background pixmap to that selected */
}
}
+
void FormDocument::BulletBMTableCB(FL_OBJECT * ob, long)
{
- FormDocument * pre = (FormDocument*)ob->form->u_vdata;
+ FormDocument * pre = static_cast<FormDocument*>(ob->form->u_vdata);
pre->BulletBMTable(ob,0);
pre->bc_->valid(pre->CheckDocumentInput(ob,0));
}
+
void FormDocument::BulletBMTable(FL_OBJECT * ob, long /*data*/ )
{
/* handle the user input by setting the current bullet depth's pixmap */
param.temp_bullets[current_bullet_depth].setFont(current_bullet_panel);
param.temp_bullets[current_bullet_depth].setCharacter(bmtable_button);
fl_set_input(bullets_->input_bullet_latex,
- param.temp_bullets[current_bullet_depth].c_str());
+ param.temp_bullets[current_bullet_depth].getText().c_str());
}
+
void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
{
if (!ob)
ProhibitInput(lv_->view());
int tc;
- const char * tct;
+ string tct;
#ifdef USE_CLASS_COMBO
tc = combo_doc_class->get();
AllowInput(lv_->view());
}
+
void FormDocument::UpdateLayoutDocument(BufferParams const & params)
{
if (!dialog_)
Toolbar::Pimpl::toolbarItem &
-Toolbar::Pimpl::toolbarItem::operator=(const toolbarItem & ti) {
+Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) {
// Are we assigning the object onto itself?
if (this == &ti)
return *this;
using std::endl;
using std::ios;
+
EPS_Renderer::EPS_Renderer()
: Renderer()
{}
-EPS_Renderer::~EPS_Renderer()
-{}
bool EPS_Renderer::renderImage()
{
return false;
}
+
bool EPS_Renderer::isImageFormatOK(string const & filename) const
{
- std::ifstream is(filename.c_str(), ios::in);
+ std::ifstream is(filename.c_str());
// The signature of the file without the spaces.
static const char str[] = "%!PS";
public:
/// c-tor.
EPS_Renderer();
- /// d-tor.
- virtual ~EPS_Renderer();
/// Load the EPS image and create a pixmap out of it.
virtual bool renderImage();
-
private:
/// Verify that filename is really an EPS file.
virtual bool isImageFormatOK(string const & filename) const;
GraphicsCache *
GraphicsCache::getInstance()
{
- if (! singleton) {
- singleton = new GraphicsCache;
+ if (!singleton) {
+ singleton = new GraphicsCache;
Assert(singleton != 0);
- }
+ }
- return singleton;
+ return singleton;
}
{
// Free the map.
//std::foreach(map.begin(), map.end(), ...);
+#warning This is a bogus reason to not clean up after your self. (Lgb)
+ // Clean up and be done with it. (Lgb)
+
// This is not really needed, it will only happen on program close and in
// any case the OS will release those resources (not doing it may have
// a good effect on closing time).
-
- delete singleton;
+
+ delete singleton;
}
GraphicsCacheItem *
GraphicsCache::addFile(string const & filename)
{
- CacheType::const_iterator it = cache.find(filename);
-
- if (it != cache.end()) {
- return new GraphicsCacheItem( *((*it).second) );
- }
+ CacheType::const_iterator it = cache.find(filename);
+
+ if (it != cache.end()) {
+ return new GraphicsCacheItem( *((*it).second) );
+ }
GraphicsCacheItem * cacheItem = new GraphicsCacheItem();
if (cacheItem == 0)
return 0;
-
+
cacheItem->setFilename(filename);
-
+
cache[filename] = cacheItem;
-
+
// We do not want to return the main cache object, otherwise when the
// will destroy their copy they will destroy the main copy.
- return new GraphicsCacheItem( *cacheItem );
+ return new GraphicsCacheItem( *cacheItem );
}
*/
class GraphicsCache : public noncopyable {
public:
- /// Get the instance of the class.
- static GraphicsCache * getInstance();
+ /// Get the instance of the class.
+ static GraphicsCache * getInstance();
- /// Add a file to the cache.
- GraphicsCacheItem * addFile(string const & filename);
+ /// Add a file to the cache.
+ GraphicsCacheItem * addFile(string const & filename);
private:
- /// Remove a cache item if it's count has gone to zero.
- void removeFile(string const & filename);
-
- /// Private c-tor so we can control how many objects are instantiated.
- GraphicsCache() {}
-
- /// Private d-tor so that no-one will destroy us.
- ~GraphicsCache();
-
- /// Holder of the single instance of the class.
- static GraphicsCache * singleton;
- ///
- typedef std::map<string, GraphicsCacheItem *> CacheType;
- ///
- CacheType cache;
-
- // We need this so that an Item can tell the cache that it should be
- // deleted. (to call removeFile).
- // It also helps removing a warning gcc emits.
+ /// Remove a cache item if it's count has gone to zero.
+ void removeFile(string const & filename);
+
+ /// Private c-tor so we can control how many objects are instantiated.
+ GraphicsCache() {}
+
+ /// Private d-tor so that no-one will destroy us.
+ ~GraphicsCache();
+
+ /// Holder of the single instance of the class.
+ static GraphicsCache * singleton;
+ ///
+ typedef std::map<string, GraphicsCacheItem *> CacheType;
+ ///
+ CacheType cache;
+
+ /** We need this so that an Item can tell the cache that it should be
+ deleted. (to call removeFile).
+ It also helps removing a warning gcc emits. */
friend class GraphicsCacheItem;
};
#endif
#include "graphics/GraphicsCacheItem.h"
#include "graphics/GraphicsCacheItem_pimpl.h"
+
GraphicsCacheItem::GraphicsCacheItem()
: pimpl(new GraphicsCacheItem_pimpl)
{
pimpl->refCount = 1;
}
+
GraphicsCacheItem::~GraphicsCacheItem()
{
destroy();
}
+
bool
GraphicsCacheItem::setFilename(string const & filename)
{
return pimpl->setFilename(filename);
}
+
GraphicsCacheItem::GraphicsCacheItem(GraphicsCacheItem const & gci)
{
pimpl = 0;
copy(gci);
}
-GraphicsCacheItem const &
+GraphicsCacheItem &
GraphicsCacheItem::operator=(GraphicsCacheItem const & gci)
{
// Are we trying to copy the object onto itself.
if (this == &gci)
return *this;
- // Destory old copy
+ // Destroy old copy
destroy();
// And then copy new object.
return *this;
}
+
void
GraphicsCacheItem::copy(GraphicsCacheItem const & gci)
{
++(pimpl->refCount);
}
+
void
GraphicsCacheItem::destroy()
{
}
}
+
GraphicsCacheItem::ImageStatus
GraphicsCacheItem::getImageStatus() const { return pimpl->imageStatus_; }
+
int
GraphicsCacheItem::getHeight() const { return pimpl->height_; }
-
+
+
int
GraphicsCacheItem::getWidth() const { return pimpl->width_; }
+
Pixmap
GraphicsCacheItem::getImage() const { return pimpl->pixmap_; }
/// copy c-tor.
GraphicsCacheItem(GraphicsCacheItem const &);
/// Assignment operator.
- GraphicsCacheItem const & operator=(GraphicsCacheItem const &);
+ GraphicsCacheItem & operator=(GraphicsCacheItem const &);
/// Get the height of the image. Returns -1 on error.
int getHeight() const;
#include <config.h>
+#include <map>
+
+#include <unistd.h> // unlink
+
+#include FORMS_H_LOCATION
+
#ifdef __GNUG__
#pragma implementation
#endif
#include "support/filetools.h"
#include "debug.h"
#include "support/LAssert.h"
-#include <unistd.h> // unlink
-
-#include <map>
-
-#include FORMS_H_LOCATION
using std::endl;
using std::map;
pixmap_(0), renderer(0), refCount(0)
{}
+
GraphicsCacheItem_pimpl::~GraphicsCacheItem_pimpl()
{
if (imageStatus_ == GraphicsCacheItem::Loaded) {
delete renderer;
}
+
bool
GraphicsCacheItem_pimpl::setFilename(string const & filename)
{
return false;
}
+
/*** Callback method ***/
typedef map<string, GraphicsCacheItem_pimpl*> CallbackMap;
static CallbackMap callbackMap;
+
void
callback(string cmd, int retval)
{
- lyxerr << "callback, cmd="<<cmd<<", retval="<<retval<<endl;
+ lyxerr << "callback, cmd=" << cmd << ", retval=" << retval << endl;
GraphicsCacheItem_pimpl * item = callbackMap[cmd];
callbackMap.erase(cmd);
item->imageConverted(retval);
}
+
void
GraphicsCacheItem_pimpl::imageConverted(int retval)
{
- lyxerr << "imageConverted, retval="<<retval<<endl;
+ lyxerr << "imageConverted, retval=" << retval << endl;
if (retval) {
imageStatus_ = GraphicsCacheItem::ErrorConverting;
// Take only the filename part of the file, without path or extension.
string temp = OnlyFilename(filename);
- temp = ChangeExtension(filename , string());
+ temp = ChangeExtension(filename, string());
// Add some stuff to have it a unique temp file.
xpmfile = TmpFileName(string(), temp);
// There is a problem with running it asyncronously, it doesn't return
// to call the callback, so until the Systemcalls mechanism is fixed
// I use the syncronous method.
- lyxerr << "Launching convert to xpm, command="<<command<<endl;
+ lyxerr << "Launching convert to xpm, command=" << command << endl;
// syscall.startscript(Systemcalls::DontWait, command, &callback);
syscall.startscript(Systemcalls::Wait, command, &callback);
return true;
}
+
// This function gets called from the callback after the image has been
// converted successfully.
void
GraphicsCacheItem_pimpl::loadXPMImage()
{
- if (! renderer->setFilename(xpmfile)) {
+ if (!renderer->setFilename(xpmfile)) {
return;
}
/// Is the pixmap ready for display?
ImageStatus getImageStatus() const;
- /// Get a notification when the image conversion is done.
- /// used by an internal callback mechanism.
+ /** Get a notification when the image conversion is done.
+ used by an internal callback mechanism. */
void imageConverted(int retval);
private:
- /// Private c-tor so that only GraphicsCache can create an instance.
- GraphicsCacheItem_pimpl();
+ /// Private c-tor so that only GraphicsCache can create an instance.
+ GraphicsCacheItem_pimpl();
/// Set the filename this item will be pointing too.
bool setFilename(string const & filename);
/// Load the image from XPM to memory Pixmap
void loadXPMImage();
- ///
- friend class GraphicsCacheItem;
+ ///
+ friend class GraphicsCacheItem;
/// The file name of the XPM file.
string xpmfile;
Renderer::Renderer()
: width_(0), height_(0), pixmapLoaded_(false)
{}
-
+
+
Renderer::~Renderer()
{
freePixmap();
}
+
bool Renderer::setFilename(string const & filename)
{
// Make sure file exists and is readable.
return true;
}
+
bool Renderer::renderImage()
{
return false;
}
+
bool Renderer::isImageFormatOK(string const & /*filename*/) const
{
return false;
}
-void Renderer::setPixmap(Pixmap pixmap, unsigned int width, unsigned int height)
+
+void Renderer::setPixmap(Pixmap pixmap,
+ unsigned int width, unsigned int height)
{
freePixmap();
pixmapLoaded_ = true;
}
+
Pixmap Renderer::getPixmap() const
-{ return pixmap_; }
+{
+ return pixmap_;
+}
+
unsigned int Renderer::getWidth() const
-{ return width_; }
+{
+ return width_;
+}
+
unsigned int Renderer::getHeight() const
-{ return height_; }
+{
+ return height_;
+}
+
string const & Renderer::getFilename() const
-{ return filename_; }
+{
+ return filename_;
+}
+
void Renderer::freePixmap()
{
bool XPM_Renderer::isImageFormatOK(string const & filename) const
{
- std::ifstream is(filename.c_str(), ios::in);
+ std::ifstream is(filename.c_str());
// The signature of the file without the spaces.
static const char str[] = "/*XPM*/";
using std::find;
using std::flush;
using std::endl;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
using std::ostringstream;
-#endif
+//#endif
extern BufferView * current_view;
extern FL_OBJECT * figinset_canvas;
ofs.close(); // Don't remove this.
// gs process - set ghostview environment first
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
ostringstream t2;
-#else
- char tbuf2[80];
- ostrstream t2(tbuf2, sizeof(tbuf2));
-#endif
+//#else
+// char tbuf2[80];
+// ostrstream t2(tbuf2, sizeof(tbuf2));
+//#endif
t2 << "GHOSTVIEW=" << fl_get_canvas_id(figinset_canvas)
<< ' ' << p->data->bitmap;
-#ifndef HAVE_SSTREAM
- t2 << '\0';
-#endif
+//#ifndef HAVE_SSTREAM
+// t2 << '\0';
+//#endif
// now set up ghostview property on a window
// #warning BUG seems that the only bug here
// might be the hardcoded dpi.. Bummer!
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
ostringstream t1;
-#else
- char tbuf[384];
- ostrstream t1(tbuf, sizeof(tbuf));
-#endif
+//#else
+// char tbuf[384];
+// ostrstream t1(tbuf, sizeof(tbuf));
+//#endif
t1 << "0 0 0 0 " << p->data->wid << ' '
<< p->data->hgh << " 72 72 0 0 0 0";
-#ifndef HAVE_SSTREAM
- t1 << '\0';
-#endif
+//#ifndef HAVE_SSTREAM
+// t1 << '\0';
+//#endif
if (lyxerr.debugging()) {
lyxerr << "Will set GHOSTVIEW property to ["
::sleep(1);
XGrabServer(tempdisp);
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp, "GHOSTVIEW", false),
8, PropModeAppend,
reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str().c_str())),
t1.str().size());
-#else
-
- XChangeProperty(tempdisp,
- fl_get_canvas_id(figinset_canvas),
- XInternAtom(tempdisp, "GHOSTVIEW", false),
- XInternAtom(tempdisp, "STRING", false),
- 8, PropModeAppend,
- reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str())),
- ::strlen(t1.str()));
-#endif
+//#else
+//
+// XChangeProperty(tempdisp,
+// fl_get_canvas_id(figinset_canvas),
+// XInternAtom(tempdisp, "GHOSTVIEW", false),
+// XInternAtom(tempdisp, "STRING", false),
+// 8, PropModeAppend,
+// reinterpret_cast<unsigned char*>(const_cast<char*>(t1.str())),
+// ::strlen(t1.str()));
+//#endif
XUngrabServer(tempdisp);
XFlush(tempdisp);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
ostringstream t3;
-#else
- //char tbuf[384];
- ostrstream t3(tbuf, sizeof(tbuf));
-#endif
+//#else
+// //char tbuf[384];
+// ostrstream t3(tbuf, sizeof(tbuf));
+//#endif
switch (p->data->flags & 3) {
case 0: t3 << 'H'; break; // Hidden
case 1: t3 << 'M'; break; // Mono
t3 << ' ' << BlackPixelOfScreen(DefaultScreenOfDisplay(tempdisp))
<< ' ' << background_pixel;
-#ifndef HAVE_SSTREAM
- t3 << '\0';
-#endif
+//#ifndef HAVE_SSTREAM
+// t3 << '\0';
+//#endif
XGrabServer(tempdisp);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp,
8, PropModeReplace,
reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str().c_str())),
t3.str().size());
-#else
- XChangeProperty(tempdisp,
- fl_get_canvas_id(figinset_canvas),
- XInternAtom(tempdisp,
- "GHOSTVIEW_COLORS", false),
- XInternAtom(tempdisp, "STRING", false),
- 8, PropModeReplace,
- reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str())),
- ::strlen(t3.str()));
-#endif
+//#else
+// XChangeProperty(tempdisp,
+// fl_get_canvas_id(figinset_canvas),
+// XInternAtom(tempdisp,
+// "GHOSTVIEW_COLORS", false),
+// XInternAtom(tempdisp, "STRING", false),
+// 8, PropModeReplace,
+// reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str())),
+// ::strlen(t3.str()));
+//#endif
XUngrabServer(tempdisp);
XFlush(tempdisp);
++ne;
typedef char * char_p;
env = new char_p[ne + 2];
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
string tmp = t2.str().c_str();
env[0] = new char[tmp.size() + 1];
std::copy(tmp.begin(), tmp.end(), env[0]);
env[0][tmp.size()] = '\0';
-#else
- env[0] = tbuf2;
-#endif
+//#else
+// env[0] = tbuf2;
+//#endif
::memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
environ = env;
}
-char const * InsetFig::EditMessage() const
+string const InsetFig::EditMessage() const
{
return _("Opened figure");
}
}
-void InsetFig::Preview(char const * p)
+void InsetFig::Preview(string const & p)
{
int pid = fork();
void Validate(LaTeXFeatures & features) const;
/// what appears in the minibuffer when opening
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
void CallbackFig(long arg);
///
- void Preview(char const * p);
+ void Preview(string const & p);
/// browse for file
void BrowseFile();
}
-LyXFont Inset::ConvertFont(LyXFont const & font) const
+LyXFont const Inset::ConvertFont(LyXFont const & font) const
{
return LyXFont(font);
}
-char const * Inset::EditMessage() const
+string const Inset::EditMessage() const
{
return _("Opened inset");
}
}
-string InsetBibKey::getScreenLabel() const
+string const InsetBibKey::getScreenLabel() const
{
if (! getOptions().empty())
return getOptions();
}
-string InsetBibtex::getScreenLabel() const
+string const InsetBibtex::getScreenLabel() const
{
return _("BibTeX Generated References");
}
// This method returns a comma separated list of Bibtex entries
-vector<pair<string,string> > InsetBibtex::getKeys() const
+vector<pair<string, string> > const InsetBibtex::getKeys() const
{
// This hack is copied from InsetBibtex::Latex.
// Is it still needed? Probably yes.
// ale070405
-string bibitemWidest(BufferView * bv)
+string const bibitemWidest(BufferView * bv)
{
int w = 0;
// Does look like a hack? It is! (but will change at 0.13)
///
void Read(Buffer const *, LyXLex & lex);
///
- virtual string getScreenLabel() const;
+ virtual string const getScreenLabel() const;
///
void Edit(BufferView *, int x, int y, unsigned int button);
///
///
Inset * Clone() const { return new InsetBibtex(params(), owner); }
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool freespace) const;
///
- std::vector<std::pair<string,string> > getKeys() const;
+ std::vector<std::pair<string,string> > const getKeys() const;
///
bool addDatabase(string const &);
///
protected:
/// This should provide the text for the button
- virtual string getScreenLabel() const = 0;
+ virtual string const getScreenLabel() const = 0;
};
#endif
: InsetCommand(p)
{}
-string InsetCitation::getScreenLabel() const
+string const InsetCitation::getScreenLabel() const
{
string keys(getContents());
return '[' + label + ']';
}
+
void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
{
bv->owner()->getDialogs()->showCitation( this );
///
Inset * Clone() const { return new InsetCitation(params()); }
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
{}
-string InsetCommandParams::getAsString() const
+string const InsetCommandParams::getAsString() const
{
string b(cmdname);
b += "|++|" + options + "|++|" + contents;
bool InsetCommandParams::operator==(InsetCommandParams const & o) const
{
- if( cmdname != o.cmdname ) return false;
- if( contents != o.contents ) return false;
- if( options != o.options ) return false;
- return true;
+ if (cmdname == o.cmdname && contents == o.contents && options == o.options) return true;
+ return false;
}
bool InsetCommandParams::operator!=(InsetCommandParams const & o) const
{
- if( cmdname != o.cmdname ) return true;
- if( contents != o.contents ) return true;
- if( options != o.options ) return true;
- return false;
+ return !(*this == o);
}
}
-string InsetCommandParams::getCommand() const
+string const InsetCommandParams::getCommand() const
{
string s;
if (!getCmdName().empty()) s += "\\"+getCmdName();
///
void Write(std::ostream &) const;
/// Build the complete LaTeX command
- string getCommand() const;
+ string const getCommand() const;
///
string const & getCmdName() const { return cmdname; }
///
///
void setContents(string const & c) { contents = c; }
///
- string getAsString() const;
+ string const getAsString() const;
///
void setFromString( string const & );
private:
confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale)
*/
- virtual string getScreenLabel() const = 0;
+ virtual string const getScreenLabel() const = 0;
///
- string getCommand() const { return p_.getCommand(); }
+ string const getCommand() const { return p_.getCommand(); }
///
string const & getCmdName() const { return p_.getCmdName(); }
///
}
-char const * InsetError::EditMessage() const
+string const InsetError::EditMessage() const
{
return _("Opened error");
}
///
bool AutoDelete() const;
/// what appears in the minibuffer when opening
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int x, int y, unsigned int button);
///
}
-char const * InsetERT::EditMessage() const
+string const InsetERT::EditMessage() const
{
return _("Opened ERT Inset");
}
///
Inset * Clone() const;
///
- char const * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInset(BufferView *, Inset *) { return false; }
///
}
-char const * InsetExternal::EditMessage() const
+string const InsetExternal::EditMessage() const
{
ExternalTemplate const & et = getTemplate(templatename);
- return doSubstitution(0, et.guiName).c_str();
+ return doSubstitution(0, et.guiName);
}
}
-string InsetExternal::getScreenLabel() const
+string const InsetExternal::getScreenLabel() const
{
if (templatename.empty()) {
return _("External");
}
-string InsetExternal::doSubstitution(Buffer const * buffer,
+string const InsetExternal::doSubstitution(Buffer const * buffer,
string const & s) const
{
string result;
}
-string InsetExternal::getCurrentTemplate() const
+string const InsetExternal::getCurrentTemplate() const
{
return getTemplateName(fl_get_choice(form_external->templatechoice));
}
-ExternalTemplate InsetExternal::getTemplate(string const & name) const
+ExternalTemplate const InsetExternal::getTemplate(string const & name) const
{
ExternalTemplateManager::Templates::const_iterator i =
ExternalTemplateManager::get().getTemplates().find(name);
}
-string InsetExternal::getTemplateName(int i) const
+string const InsetExternal::getTemplateName(int i) const
{
ExternalTemplateManager::Templates::const_iterator i1;
i1 = ExternalTemplateManager::get().getTemplates().begin();
}
-string InsetExternal::getTemplateString() const
+string const InsetExternal::getTemplateString() const
{
string result;
bool first = true;
///
virtual ~InsetExternal();
/// what appears in the minibuffer when opening
- virtual char const * EditMessage() const;
+ virtual string const EditMessage() const;
///
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual Inset * Clone() const;
/// returns the text of the button
- virtual string getScreenLabel() const;
+ virtual string const getScreenLabel() const;
/// Callback function for the template drop-down
static void templateCB(FL_OBJECT *, long);
void doView(BufferView const *) const;
/// Substitute meta-variables in this string
- string doSubstitution(Buffer const *, string const & s) const;
+ string const doSubstitution(Buffer const *, string const & s) const;
/** Get the LyX name of the currently selected
template in the choice list
*/
- string getCurrentTemplate() const;
+ string const getCurrentTemplate() const;
/// Get a certain template from a LyX name
- ExternalTemplate getTemplate(string const & lyxname) const;
+ ExternalTemplate const getTemplate(string const & lyxname) const;
/**
- * Get the number starting from 1 of a template with a
- * specific LyX name for the choice list
+ Get the number starting from 1 of a template with a
+ specific LyX name for the choice list
*/
int getTemplateNumber(string const & guiname) const;
/// Get the LyX name of a template with a given number starting from 1
- string getTemplateName(int n) const;
+ string const getTemplateName(int n) const;
/// Get a string with all the GUI template names separated by |
- string getTemplateString() const;
+ string const getTemplateString() const;
///
struct Holder {
}
-char const * InsetFloat::EditMessage() const
+string const InsetFloat::EditMessage() const
{
return _("Opened Float Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
///
}
-char const * InsetFoot::EditMessage() const
+string const InsetFoot::EditMessage() const
{
return _("Opened Footnote Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
};
updateInset();
}
-static void formatResize(ostream & os, char const *key,
- InsetGraphicsParams::Resize resizeType, double size)
+static
+void formatResize(ostream & os, string const & key,
+ InsetGraphicsParams::Resize resizeType, double size)
{
switch (resizeType) {
case InsetGraphicsParams::DEFAULT_SIZE:
// Calculate the options part of the command, we must do it to a string
// stream since we might have a trailing comma that we would like to remove
// before writing it to the output stream.
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream options;
-#else
- ostrstream options;
-#endif
+//#else
+// ostrstream options;
+//#endif
formatResize(options, "width", params.widthResize, params.widthSize);
formatResize(options, "height", params.heightResize, params.heightSize);
}
#endif
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
string opts(options.str().c_str());
-#else
- options << '\0';
- char * tmp = options.str();
- string opts(tmp);
- delete [] tmp;
-#endif
+//#else
+// options << '\0';
+// char * tmp = options.str();
+// string opts(tmp);
+// delete [] tmp;
+//#endif
opts = strip(opts, ',');
///
#ifdef SIGC_CXX_NAMESPACES
class InsetGraphics : public Inset, public SigC::Object
-{
#else
class InsetGraphics : public Inset, public Object
+#endif
{
-#endif
public:
///
InsetGraphics();
void Read(Buffer const *, LyXLex & lex);
/** returns the number of rows (\n's) of generated tex code.
- fragile == true means, that the inset should take care about
- fragile commands by adding a \protect before.
+ #fragile == true# means, that the inset should take care about
+ fragile commands by adding a #\protect# before.
*/
int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
int DocBook(Buffer const *, std::ostream &) const;
/** Tell LyX what the latex features you need i.e. what latex packages
- * you need to be included.
- */
+ you need to be included.
+ */
void Validate(LaTeXFeatures & features) const;
/// returns LyX code associated with the inset. Used for TOC, ...)
///
Inset * Clone() const;
- /// Set the inset parameters, used by the GUIndependent dialog.
- /// Return true of new params are different from what was so far.
+ /** Set the inset parameters, used by the GUIndependent dialog.
+ Return true of new params are different from what was so far.
+ */
bool setParams(InsetGraphicsParams const & params);
/// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams getParams() const;
- /// This signal is connected by our dialog and called when the inset
- /// is deleted.
- Signal0 < void > hide;
+ /** This signal is connected by our dialog and called when the inset
+ is deleted.
+ */
+ Signal0 <void> hide;
private:
/// Update the inset after parameter change.
void updateInset();
copy(igp);
}
-InsetGraphicsParams const &
-InsetGraphicsParams::operator=(InsetGraphicsParams const ¶ms)
+InsetGraphicsParams &
+InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
{
// Are we assigning the object into itself?
if (this == ¶ms)
return false;
}
-static void writeResize(ostream & os, char const * key,
+
+static
+void writeResize(ostream & os, string const & key,
InsetGraphicsParams::Resize resize, double size)
{
os << ' ' << key << "Resize ";
REFERENCE_POINT = LEFTBASELINE
};
- /// The resize of the image, is it the default size, in cm, inch or
- /// percentage of the page/column width/height
+ /** The resize of the image, is it the default size, in cm, inch or
+ percentage of the page/column width/height */
enum Resize {
DEFAULT_SIZE,
CM,
/// Keep the ratio between height and width when resizing.
bool keepAspectRatio;
- // What width resize to do?
+ /// What width resize to do?
Resize widthResize;
- // Value of width resize
+ /// Value of width resize
float widthSize;
- // What height resize to do?
+ /// What height resize to do?
Resize heightResize;
- // Value of height resize
+ /// Value of height resize
float heightSize;
- // Origin point of rotation
+ /// Origin point of rotation
Origin rotateOrigin;
- // Rotation angle.
+ /// Rotation angle.
int rotateAngle;
-
+ ///
InsetGraphicsParams();
-
+ ///
InsetGraphicsParams(InsetGraphicsParams const &);
- InsetGraphicsParams const & operator=(InsetGraphicsParams const &);
+ ///
+ InsetGraphicsParams & operator=(InsetGraphicsParams const &);
/// Save the parameters in the LyX format stream.
void Write(Buffer const * buf, ostream & os) const;
void copy(InsetGraphicsParams const & params);
};
-bool operator==(InsetGraphicsParams const&, InsetGraphicsParams const &);
+///
+bool operator==(InsetGraphicsParams const &, InsetGraphicsParams const &);
#endif
}
-static string unique_id() {
+static inline
+string unique_id() {
static unsigned int seed=1000;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
ost << "file" << ++seed;
// Needed if we use lyxstring.
return ost.str().c_str();
-#else
- char ctmp[16];
- ostrstream ost(ctmp,16);
- ost << "file" << ++seed << '\0';
-
- // Needed if we use lyxstring.
- return ost.str();
-#endif
+//#else
+// char ctmp[16];
+// ostrstream ost(ctmp,16);
+// ost << "file" << ++seed << '\0';
+//
+// // Needed if we use lyxstring.
+// return ost.str();
+//#endif
}
}
-string InsetInclude::getScreenLabel() const
+string const InsetInclude::getScreenLabel() const
{
string temp;
if (isInput())
}
-string InsetInclude::getFileName() const
+string const InsetInclude::getFileName() const
{
return MakeAbsPath(getContents(),
OnlyPath(getMasterFilename()));
}
-string InsetInclude::getMasterFilename() const
+string const InsetInclude::getMasterFilename() const
{
return master->fileName();
}
}
-vector<string> InsetInclude::getLabelList() const
+vector<string> const InsetInclude::getLabelList() const
{
vector<string> l;
string parentname;
}
-vector<pair<string,string> > InsetInclude::getKeys() const
+vector<pair<string,string> > const InsetInclude::getKeys() const
{
vector<pair<string,string> > keys;
///
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
/// This returns the list of labels on the child buffer
- std::vector<string> getLabelList() const;
+ std::vector<string> const getLabelList() const;
/// This returns the list of bibkeys on the child buffer
- std::vector< std::pair<string,string> > getKeys() const;
+ std::vector< std::pair<string,string> > const getKeys() const;
///
void Edit(BufferView *, int x, int y, unsigned int button);
///
*/
bool display() const;
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
- string getMasterFilename() const;
+ string const getMasterFilename() const;
///
- string getFileName() const;
+ string const getFileName() const;
/// In "input" mode uses \input instead of \include.
bool isInput() const { return flag == InsetInclude::INPUT; }
{}
-string InsetIndex::getScreenLabel() const
+string const InsetIndex::getScreenLabel() const
{
return _("Idx");
}
: InsetCommand(p)
{}
-string InsetPrintIndex::getScreenLabel() const
+string const InsetPrintIndex::getScreenLabel() const
{
return _("Index");
}
///
Inset * Clone() const { return new InsetIndex(params());}
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
///
Inset::Code LyxCode() const;
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
};
#endif
}
-char const * InsetInfo::EditMessage() const
+string const InsetInfo::EditMessage() const
{
return _("Opened note");
}
///
int DocBook(Buffer const *, std::ostream &) const;
/// what appears in the minibuffer when opening
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
{}
-vector<string> InsetLabel::getLabelList() const
+vector<string> const InsetLabel::getLabelList() const
{
return vector<string>(1,getContents());
}
// This function escapes 8-bit characters and other problematic characters
// It's exactly the same code as in insetref.C.
-string InsetLabel::escape(string const & lab) const {
+string const InsetLabel::escape(string const & lab) const {
char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
string enc;
///
Inset * Clone() const { return new InsetLabel(params()); }
///
- string getScreenLabel() const { return getContents(); }
+ string const getScreenLabel() const { return getContents(); }
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
///
void Edit(BufferView *, int, int, unsigned int);
///
- std::vector<string> getLabelList() const;
+ std::vector<string> const getLabelList() const;
///
int Latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
int DocBook(Buffer const *, std::ostream &) const;
private:
/// This function escapes 8-bit characters
- string escape(string const &) const;
+ string const escape(string const &) const;
};
#endif
}
-char const * InsetList::EditMessage() const
+string const InsetList::EditMessage() const
{
return _("Opened List Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
};
}
-char const * InsetMarginal::EditMessage() const
+string const InsetMarginal::EditMessage() const
{
return _("Opened Marginal Note Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
};
}
-char const * InsetMinipage::EditMessage() const
+string const InsetMinipage::EditMessage() const
{
return _("Opened Minipage Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
};
using std::ostream;
+
InsetParent::InsetParent(InsetCommandParams const & p, Buffer * bf)
: InsetCommand(p)
{
}
-string InsetParent::getScreenLabel() const
+string const InsetParent::getScreenLabel() const
{
return string(_("Parent:")) + getContents();
}
///
Inset * Clone() const { return new InsetParent(params()); }
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
}
-string InsetQuotes::DispString() const
+string const InsetQuotes::DispString() const
{
string disp;
disp += quote_char[quote_index[side][language]];
}
-//LyXFont InsetQuotes::ConvertFont(LyXFont font)
-// I really belive this should be
-LyXFont InsetQuotes::ConvertFont(LyXFont const & f) const
+LyXFont const InsetQuotes::ConvertFont(LyXFont const & f) const
{
LyXFont font(f);
// quotes-insets cannot be latex of any kind
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
///
- LyXFont ConvertFont(LyXFont const & font) const;
- //LyXFont ConvertFont(LyXFont font);
+ LyXFont const ConvertFont(LyXFont const & font) const;
///
void Write(Buffer const *, std::ostream &) const;
///
///
void ParseString(string const &);
///
- string DispString() const;
+ string const DispString() const;
};
#endif
}
-string InsetRef::getScreenLabel() const
+string const InsetRef::getScreenLabel() const
{
string temp;
if (getCmdName() == "ref")
// This function escapes 8-bit characters and other problematic characters
// It's exactly the same code as in insetlabel.C.
-string InsetRef::escape(string const & lab) const
+string const InsetRef::escape(string const & lab) const
{
char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
return enc;
}
+
void InsetRef::Validate(LaTeXFeatures & features) const
{
if (getCmdName() == "vref" || getCmdName() == "vpageref")
///
Inset * Clone() const { return new InsetRef(params()); }
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
void Validate(LaTeXFeatures & features) const;
private:
/// This function escapes 8-bit characters
- string escape(string const &) const;
+ string const escape(string const &) const;
};
#endif
{ LyXTabular::LAST_ACTION, "" }
};
-//#define cellstart(p) ((p % 2) == 0)
+
static inline
bool cellstart(LyXParagraph::size_type p)
{
}
-char const * InsetTabular::EditMessage() const
+string const InsetTabular::EditMessage() const
{
return _("Opened Tabular Inset");
}
setLines = 0,
setAlign = LYX_ALIGN_LEFT,
lineSet;
- bool
- what;
+ bool what;
switch (feature) {
case LyXTabular::M_ALIGN_LEFT:
*
* LyX, The Document Processor
*
- * Copyright (C) 1995-2000 The LyX Team.
+ * Copyright 1995-2000 The LyX Team.
*
*======================================================
*/
///
void update(BufferView *, LyXFont const &, bool = false);
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int x, int y, unsigned int);
///
void OpenLayoutDialog(BufferView *) const;
LyXFunc::func_status getStatus(string argument) const;
- ///
- /// Public structures and variables
+ //
+ // Public structures and variables
///
LyXTabular * tabular;
private:
-
+ ///
bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
bool =false) const;
///
void setPos(BufferView *, int x, int y) const;
///
UpdatableInset::RESULT moveRight(BufferView *, bool lock = true);
+ ///
UpdatableInset::RESULT moveLeft(BufferView *, bool lock = true);
+ ///
UpdatableInset::RESULT moveUp(BufferView *);
+ ///
UpdatableInset::RESULT moveDown(BufferView *);
+ ///
bool moveNextCell(BufferView *);
+ ///
bool movePrevCell(BufferView *);
+ ///
bool Delete();
///
int getCellXPos(int cell) const;
+ ///
void resetPos(BufferView *) const;
///
void RemoveTabularRow();
bool hasPasteBuffer() const { return (paste_tabular != 0); }
///
bool copySelection();
+ ///
bool pasteSelection(BufferView *);
+ ///
bool cutSelection();
- ///
- /// Private structures and variables
+ //
+ // Private structures and variables
///
InsetText * the_locking_inset;
+ ///
Buffer * buffer;
- mutable LyXCursor
- cursor,
- old_cursor;
- mutable int
- inset_pos,
- inset_x, inset_y,
- sel_pos_start,
- sel_pos_end,
- sel_cell_start,
- sel_cell_end,
- actcell,
- oldcell,
- actcol,
- actrow;
+ ///
+ mutable LyXCursor cursor;
+ ///
+ mutable LyXCursor old_cursor;
+ ///
+ mutable int inset_pos;
+ ///
+ mutable int inset_x;
+ ///
+ mutable int inset_y;
+ ///
+ mutable int sel_pos_start;
+ ///
+ mutable int sel_pos_end;
+ ///
+ mutable int sel_cell_start;
+ ///
+ mutable int sel_cell_end;
+ ///
+ mutable int actcell;
+ ///
+ mutable int oldcell;
+ ///
+ mutable int actcol;
+ ///
+ mutable int actrow;
+ ///
bool no_selection;
+ ///
mutable bool locked;
+ ///
mutable UpdateCodes need_update;
+ ///
mutable Dialogs * dialogs_;
+ ///
LyXTabular * paste_tabular;
};
#endif
*
* Copyright 1998-2000 The LyX Team.
*
- * @author: Jürgen Vigna
- *
* ======================================================
*/
return * this;
}
+
void InsetText::init(InsetText const * ins)
{
top_y = last_width = last_height = 0;
}
-char const * InsetText::EditMessage() const
+string const InsetText::EditMessage() const
{
return _("Opened Text Inset");
}
cur_value = par->spacing.getValue();
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::istringstream istr(arg.c_str());
-#else
- istrstream istr(arg.c_str());
-#endif
+//#else
+// istrstream istr(arg.c_str());
+//#endif
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
}
}
+
void InsetText::resizeLyXText(BufferView * bv) const
{
if (!par->next && !par->size()) // resize not neccessary!
/// then resize all LyXText in text-insets
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
- LyXParagraph * p = par;
- for(;p;p = p->next) {
+ for(LyXParagraph * p = par; p; p = p->next) {
p->resizeInsetsLyXText(bv);
}
}
void InsetText::removeNewlines()
{
- LyXParagraph * p = par;
-
- for(;p; p = p->next) {
+ for(LyXParagraph * p = par; p; p = p->next) {
for(int i = 0; i < p->Last(); ++i) {
if (p->GetChar(i) == LyXParagraph::META_NEWLINE)
p->Erase(i);
*
* Copyright 1998 The LyX Team.
*
- * @author: Jürgen Vigna
*
*======================================================
*/
class LyXScreen;
/**
- * A text inset is like a TeX box to write full text
- * (including styles and other insets) in a given space.
+ A text inset is like a TeX box to write full text
+ (including styles and other insets) in a given space.
+ @author: Jürgen Vigna
*/
class InsetText : public UpdatableInset {
public:
///
enum UpdateCodes {
+ ///
NONE = 0,
+ ///
INIT,
+ ///
FULL,
+ ///
CURSOR_PAR,
+ ///
CURSOR,
+ ///
SELECTION,
+ ///
DRAW_FRAME,
+ ///
CLEAR_FRAME
};
///
enum DrawFrame {
+ ///
NEVER = 0,
+ ///
LOCKED,
+ ///
ALWAYS
};
///
///
Inset * Clone() const;
///
- InsetText & operator= (InsetText const & it);
+ InsetText & operator=(InsetText const & it);
///
void clear();
///
///
void update(BufferView *, LyXFont const &, bool =false);
///
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
///
void SetFrameColor(BufferView *, LColor::color);
///
-// LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
- ///
LyXText * getLyXText(BufferView *) const;
///
void deleteLyXText(BufferView *, bool recursive=true) const;
///
void SetCharFont(Buffer const *, int pos, LyXFont const & font);
///
- string getText(int);
+ string const getText(int);
///
bool checkAndActivateInset(BufferView * bv, bool behind);
///
}
-char const * InsetTheorem::EditMessage() const
+string const InsetTheorem::EditMessage() const
{
return _("Opened Theorem Inset");
}
///
int Latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
- const char * EditMessage() const;
+ string const EditMessage() const;
///
bool InsertInsetAllowed(Inset * inset) const;
};
using std::ostream;
-string InsetTOC::getScreenLabel() const
+string const InsetTOC::getScreenLabel() const
{
string cmdname( getCmdName() );
if( cmdname == "tableofcontents" )
///
Inset * Clone() const { return new InsetTOC(params()); }
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
void Edit(BufferView * bv, int, int, unsigned int);
///
}
-string InsetUrl::getScreenLabel() const
+string const InsetUrl::getScreenLabel() const
{
string temp;
if( getCmdName() == "url" )
///
void Validate(LaTeXFeatures &) const;
///
- string getScreenLabel() const;
+ string const getScreenLabel() const;
///
EDITABLE Editable() const { return IS_EDITABLE; }
///
virtual void update(BufferView *, LyXFont const &, bool = false)
{}
///
- virtual LyXFont ConvertFont(LyXFont const & font) const;
+ virtual LyXFont const ConvertFont(LyXFont const & font) const;
/// what appears in the minibuffer when opening
- virtual const char * EditMessage() const;
+ virtual string const EditMessage() const;
///
virtual void Edit(BufferView *, int x, int y, unsigned int button);
///
/// returns LyX code associated with the inset. Used for TOC, ...)
virtual Inset::Code LyxCode() const { return NO_CODE; }
- virtual std::vector<string> getLabelList() const {
+ virtual std::vector<string> const getLabelList() const {
return std::vector<string>();
}
// This binds a key to an action
-int kb_keymap::bind(char const * seq, int action)
+int kb_keymap::bind(string const & seq, int action)
{
kb_sequence k;
}
-string kb_keymap::keyname(kb_key const & k)
+string const kb_keymap::keyname(kb_key const & k)
{
string buf;
printKeysym(k.code, k.mod, buf);
// Finds a key for a keyaction, if possible
-string kb_keymap::findbinding(int act) const
+string const kb_keymap::findbinding(int act) const
{
string res;
if (table.empty()) return res;
/** Bind a key-sequence to an action.
Returns 0 on success. Otherwise, position in string where
error occured. */
- int bind(char const * seq, int action);
+ int bind(string const & seq, int action);
///
void print(string & buf) const;
unsigned int mod, kb_sequence * seq) const;
/// Given an action, find all keybindings.
- string findbinding(int action) const;
+ string const findbinding(int action) const;
private:
///
struct kb_key {
/// Define a new key sequence
int defkey(kb_sequence * seq, int action, int idx = 0);
///
- static string keyname(kb_key const & k);
+ static string const keyname(kb_key const & k);
///
static
Prefixes are S-, C-, M- for shift, control, meta
\* ---F------------------------------------------------------------------- */
-int kb_sequence::parse(char const * s)
+int kb_sequence::parse(string const & s)
{
- if(!s[0]) return 1;
+ if(s.empty()) return 1;
int i = 0;
unsigned int mod = 0, nmod = 0;
- while(s[i]) {
+ while (i < s.length()) {
if(s[i] && (s[i]) <= ' ') ++i;
- if(!s[i]) break;
+ if(i >= s.length()) break;
if(s[i + 1] == '-') { // is implicit that s[i] == true
switch(s[i]) {
} else {
string tbuf;
int j = i;
- for(; s[j] && s[j] > ' '; ++j)
+ for(; j < s.length() && s[j] > ' '; ++j)
tbuf += s[j]; // (!!!check bounds :-)
KeySym key = XStringToKeysym(tbuf.c_str());
void reset();
///
- int parse(char const * s);
+ int parse(string const & s);
/// Keymap to use if a new sequence is starting
kb_keymap * stdmap;
typedef Files::const_iterator const_iterator;
/** Read the lastfiles file.
- @param file The file to read the lastfiles form.
- @param dostat Whether to check for file existance.
- @param num number of files to remember.
+ @param file The file to read the lastfiles form.
+ @param dostat Whether to check for file existance.
+ @param num number of files to remember.
*/
explicit
LastFiles(string const & file,
bool dostat = true, unsigned int num = 4);
- /**
- This funtion inserts #file# into the last files list. If the file
- already exist it is moved to the top of the list, else exist it
- is placed on the top of the list. If the list is full the last
- file in the list is popped from the end.
+ /** Insert #file# into the list.
+ This funtion inserts #file# into the last files list. If the file
+ already exist it is moved to the top of the list, else exist it
+ is placed on the top of the list. If the list is full the last
+ file in the list is popped from the end.
+ @param file the file to insert in the list.
*/
void newFile(string const & file);
- /** Writes the lastfiles table to disk. One file on each line, this
- way we can at least have some special chars (e.g. space), but
- newline in filenames are thus not allowed.
+ /** Writes the lastfiles table to disk.
+ Writes one file on each line, this way we can at least have
+ some special chars (e.g. space), but newline in filenames
+ are thus not allowed.
+ @param file the file we write the lastfiles list to.
*/
- void writeFile(string const &) const;
- ///
- string const operator[](unsigned int) const;
- ///
+ void writeFile(string const & file) const;
+ /** Return file #n# in the lastfiles list.
+ @param n number in the list to get
+ */
+ string const operator[](unsigned int n) const;
+ /// Iterator to the beginning of the list.
Files::const_iterator begin() const { return files.begin(); }
- ///
+ /// Iterator to the end of the list.
Files::const_iterator end() const { return files.end(); }
private:
/** Local constants.
bool dostat;
/** Read the lastfiles file.
- Reads the .lyx_lastfiles at the beginning of the LyX session.
- This will read the lastfiles file (usually .lyx_lastfiles). It
+ Reads the #.lyx_lastfiles# at the beginning of the LyX session.
+ This will read the lastfiles file (usually #.lyx_lastfiles#). It
will normally discard files that don't exist anymore, unless
- LastFiles has been initialized with dostat = false.
+ LastFiles has been initialized with #dostat = false#.
+ @param file the file containing the lastfiles.
+ */
+ void readFile(string const & file);
+ /** Used by the constructor to set the number of stored last files.
+ @param num the number of lastfiles to set.
*/
- void readFile(string const &);
- /// used by the constructor to set the number of stored last files.
void setNumberOfFiles(unsigned int num);
};
#endif
//////////////////////////////////////////
// Gets textclass number from name
-pair<bool, LyXTextClassList::size_type>
+pair<bool, LyXTextClassList::size_type> const
LyXTextClassList::NumberOfClass(string const & textclass) const
{
for (ClassList::const_iterator cit = classlist.begin();
// Gets layout number from name and textclass number
-pair<bool, LyXTextClass::size_type>
+pair<bool, LyXTextClass::size_type> const
LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass,
string const & name) const
{
}
return os;
}
+
LyXTextClass::size_type layout) const;
/// Gets layout number from textclass number and layout name
- std::pair<bool, LyXTextClass::size_type>
+ std::pair<bool, LyXTextClass::size_type> const
NumberOfLayout(size_type textclass,
string const & name) const;
/** Gets textclass number from name.
Returns -1 if textclass name does not exist
*/
- std::pair<bool, size_type>
+ std::pair<bool, size_type> const
NumberOfClass(string const & textclass) const;
///
#include <algorithm>
#include <iostream>
-//#include "LString.h"
#include FORMS_H_LOCATION
#include "lyx.h"
#include "layout_forms.h"
}
-void MenuInsertLabel(char const * arg)
+void MenuInsertLabel(string const & arg)
{
- string label = arg;
+ string label(arg);
ProhibitInput(current_view);
if (label.empty()) {
pair<bool, string>
}
-inline
+static inline
void DeactivateParagraphButtons ()
{
fl_deactivate_object (fd_form_paragraph->button_ok);
}
-inline
+static inline
void ActivateParagraphButtons ()
{
fl_activate_object (fd_form_paragraph->button_ok);
}
-inline
+static inline
void DisableParagraphLayout ()
{
DeactivateParagraphButtons();
}
-inline
+static inline
void EnableParagraphLayout ()
{
ActivateParagraphButtons();
}
#ifdef USE_OLD_DOCUMENT_LAYOUT
-inline
+static inline
void DeactivateDocumentButtons ()
{
fl_deactivate_object (fd_form_document->button_ok);
}
-inline
+static inline
void ActivateDocumentButtons ()
{
fl_activate_object (fd_form_document->button_ok);
}
-inline
+static inline
void DisableDocumentLayout ()
{
DeactivateDocumentButtons ();
}
-inline
+static inline
void EnableDocumentLayout ()
{
ActivateDocumentButtons ();
fl_set_choice(fd_form_document->choice_spacing, 4);
//char sval[20];
//sprintf(sval, "%g", params->spacing.getValue());
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream sval;
sval << params->spacing.getValue(); // setw?
fl_set_input(fd_form_document->input_spacing,
sval.str().c_str());
-#else
- char tval[20];
- ostrstream sval(tval, 20);
- sval << params->spacing.getValue() << '\0'; // setw?
- fl_set_input(fd_form_document->input_spacing, sval.str());
-#endif
+//#else
+// char tval[20];
+// ostrstream sval(tval, 20);
+// sval << params->spacing.getValue() << '\0'; // setw?
+// fl_set_input(fd_form_document->input_spacing, sval.str());
+//#endif
break;
}
}
// This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
// Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
-LyXFont UserFreeFont(BufferParams const & params)
+LyXFont const UserFreeFont(BufferParams const & params)
{
LyXFont font(LyXFont::ALL_IGNORE);
///
extern bool BindFileSet;
///
-extern LyXFont UserFreeFont(BufferParams const & params);
+extern LyXFont const UserFreeFont(BufferParams const & params);
///
void ShowMessage(Buffer * buf,
string const & msg1,
#include "layout.h"
#include "gettext.h"
#include "kbmap.h"
-#ifdef NEW_MENUBAR
-# include "MenuBackend.h"
-#endif
+#include "MenuBackend.h"
#include "ToolbarDefaults.h"
#include "lyxlex.h"
#if 1
while (lex.IsOK()) {
switch(lex.lex()) {
case ui_menuset:
-#ifdef NEW_MENUBAR
menubackend.read(lex);
break;
-#else
- // Skip any menu definition and fall over to toolbar.
- // This is a hack, but it is supposed to go away...
- do {
- lex.next();
- if (!lex.IsOK()) return;
- }
- while (lex.lex() != ui_toolbar);
-#endif
case ui_toolbar:
toolbardefaults.read(lex);
/// Build GUI description of font state
-string LyXFont::stateText(BufferParams * params) const
+string const LyXFont::stateText(BufferParams * params) const
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
-#else
- char str[1024];
- ostrstream ost(str, 1024);
-#endif
+//#else
+// char str[1024];
+// ostrstream ost(str, 1024);
+//#endif
if (family() != INHERIT_FAMILY)
ost << _(GUIFamilyNames[family()]) << ", ";
if (series() != INHERIT_SERIES)
if (!params || (language() != params->language_info &&
language()->lang() != "default"))
ost << _("Language: ") << _(language()->display().c_str());
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
string buf(ost.str().c_str());
-#else
- ost << '\0';
- string buf(ost.str());
-#endif
+//#else
+// ost << '\0';
+// string buf(ost.str());
+//#endif
buf = strip(buf, ' ');
buf = strip(buf, ',');
return buf;
// Returns size in latex format
-string LyXFont::latexSize() const
+string const LyXFont::latexSize() const
{
return LaTeXSizeNames[size()];
}
count += strlen(LaTeXShapeNames[f.shape()]) + 2;
env = true; //We have opened a new environment
}
- if (f.color() != LColor::inherit) {
+ if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
os << "\\textcolor{"
<< lcolor.getLaTeXName(f.color())
<< "}{";
++count;
env = true; // Size change need not bother about closing env.
}
- if (f.color() != LColor::inherit) {
+ if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
os << '}';
++count;
env = true; // Size change need not bother about closing env.
LyXFont & setGUISize(string const &);
/// Returns size of font in LaTeX text notation
- string latexSize() const;
+ string const latexSize() const;
/** Updates font settings according to request.
If an attribute is IGNORE, the attribute is left as it is.
LyXFont const & next) const;
/// Build GUI description of font state
- string stateText(BufferParams * params) const;
+ string const stateText(BufferParams * params) const;
///
LColor::color realColor() const;
// Returns the value of the replace string in the form
-string SearchForm::ReplaceString() const
+string const SearchForm::ReplaceString() const
{
return fl_get_input(search_form->input_replace);
}
}
///
- string SearchString() const {
+ string const SearchString() const {
return fl_get_input(search_form->input_search);
}
///
void SetSearchString(string const & ls);
///
- string ReplaceString() const;
+ string const ReplaceString() const;
///
bool ValidSearchData() const { return !(SearchString().empty()); }
#include <config.h>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
using std::istringstream;
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#include <time.h>
#include <locale.h>
#include "bufferview_funcs.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
-#ifdef NEW_MENUBAR
#include "frontends/Menubar.h"
-#else
-#include "menus.h"
-#endif
#include "FloatList.h"
#include "exporter.h"
#include "FontLoader.h"
extern bool cursor_follows_scrollbar;
extern void InsertAsciiFile(BufferView *, string const &, bool);
-extern void math_insert_symbol(char const *);
+extern void math_insert_symbol(string const &);
extern bool math_insert_greek(char);
extern BufferList bufferlist;
extern LyXServer * lyxserver;
extern bool MenuWrite(Buffer *);
extern bool MenuWriteAs(Buffer *);
-#ifdef NEW_MENUBAR
extern int MenuRunLaTeX(Buffer *);
-#endif
extern int MenuBuildProg(Buffer *);
extern int MenuRunChktex(Buffer *);
#ifndef NEW_EXPORT
extern bool PreviewDVI(Buffer *);
extern bool PreviewPostscript(Buffer *);
#endif
-extern void MenuInsertLabel(char const *);
+extern void MenuInsertLabel(string const &);
extern void MenuLayoutCharacter();
extern void MenuLayoutParagraph();
extern void MenuLayoutDocument();
}
-string LyXFunc::Dispatch(string const & s)
+string const LyXFunc::Dispatch(string const & s)
{
// Split command string into command and argument
string cmd, line = frontStrip(s);
}
-string LyXFunc::Dispatch(int ac,
- char const * do_not_use_this_arg)
+string const LyXFunc::Dispatch(int ac,
+ string const & do_not_use_this_arg)
{
string argument;
kb_action action;
argument = tmparg;
} else {
action = static_cast<kb_action>(ac);
- if (do_not_use_this_arg)
+ if (!do_not_use_this_arg.empty())
argument = do_not_use_this_arg; // except here
}
break;
case LFUN_MENU_OPEN_BY_NAME:
-#ifdef NEW_MENUBAR
owner->getMenubar()->openByName(argument);
-#else
- owner->getMenus()->openByName(argument);
-#endif
break; // RVDK_PATCH_5
case LFUN_SPELLCHECK:
cur_value = par->spacing.getValue();
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
istringstream istr(argument);
-#else
- istrstream istr(argument.c_str());
-#endif
+//#else
+// istrstream istr(argument.c_str());
+//#endif
string tmp;
istr >> tmp;
Spacing::Space new_spacing = cur_spacing;
case LFUN_GOTO_PARAGRAPH:
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
istringstream istr(argument);
-#else
- istrstream istr(argument.c_str());
-#endif
+//#else
+// istrstream istr(argument.c_str());
+//#endif
int id;
istr >> id;
LyXFunc(LyXView *);
/// LyX dispatcher, executes lyx actions.
- string Dispatch(int action, char const * arg = 0);
+ string const Dispatch(int action, string const & arg = string());
/// The same but uses the name of a lyx command.
- string Dispatch(string const & cmd);
+ string const Dispatch(string const & cmd);
/// Same again but for xtl buffers. Still looking for better idea.
bool Dispatch(int action, auto_mem_buffer &);
// These can't be global because are part of the
// internal state (ale970227)
/// Get the current keyseq string
- string keyseqStr() const;
+ string const keyseqStr() const;
/// Is the key sequence uncomplete?
bool keyseqUncomplete() const;
/// get options for the current keyseq
- string keyseqOptions() const;
+ string const keyseqOptions() const;
/// True if lyxfunc reports an error
bool errorStat() const { return errorstat; }
/// Buffer to store result messages
void setErrorMessage(string const &) const;
/// Buffer to store result messages
- string getMessage() const { return dispatch_buffer; }
+ string const getMessage() const { return dispatch_buffer; }
/// Get next inset of this class from current cursor position
Inset * getInsetByCode(Inset::Code);
inline
-string LyXFunc::keyseqStr() const
+string const LyXFunc::keyseqStr() const
{
// Why not just remove this function
string text;
inline
-string LyXFunc::keyseqOptions() const
+string const LyXFunc::keyseqOptions() const
{
// Why not just remove this function
string text;
}
-char const * const LyXLex::text() const
+string const LyXLex::text() const
{
return &pimpl_->buff[0];
}
int CheckToken(char const * str[], int print_error);
///
- char const * const text() const;
+ string const text() const;
/** Pushes a token list on a stack and replaces it with a new one.
*/
};
-/** Use to enable multipe exit points.
+/** Use to enable multiple exit points.
This is needed to ensure that the pop is done upon exit from methods
with more than one exit point or that can return as a response to
exceptions.
@autor Lgb
*/
struct pushpophelper {
+ ///
pushpophelper(LyXLex & lexrc, keyword_item * i, int s) : lex(lexrc) {
lex.pushTable(i, s);
}
+ ///
~pushpophelper() {
lex.popTable();
}
+ ///
LyXLex & lex;
};
/** Avoid wrong usage of pushpophelper.
bool isMultiLingual(BufferParams const &);
///
- string String(Buffer const *, bool label);
+ string const String(Buffer const *, bool label);
///
- string String(Buffer const *, size_type beg, size_type end);
+ string const String(Buffer const *, size_type beg, size_type end);
///
void writeFile(Buffer const *, std::ostream &, BufferParams const &,
string const & GetLabelstring() const;
/// the next two functions are for the manual labels
- string GetLabelWidthString() const;
+ string const GetLabelWidthString() const;
///
void SetLabelWidthString(string const & s);
///
between the characters font and the layoutfont.
This is what is stored in the fonttable
*/
- LyXFont GetFontSettings(BufferParams const &, size_type pos) const;
+ LyXFont const
+ GetFontSettings(BufferParams const &, size_type pos) const;
///
- LyXFont GetFirstFontSettings() const;
+ LyXFont const GetFirstFontSettings() const;
/** Get fully instantiated font. If pos == -1, use the layout
font attached to this paragraph.
attributes with values LyXFont::INHERIT, LyXFont::IGNORE or
LyXFont::TOGGLE.
*/
- LyXFont getFont(BufferParams const &, size_type pos) const;
+ LyXFont const getFont(BufferParams const &, size_type pos) const;
///
value_type GetChar(size_type pos) const;
/// The position must already exist.
///
void SetFont(size_type pos, LyXFont const & font);
///
- string GetWord(size_type &) const;
+ string const GetWord(size_type &) const;
/// Returns the height of the highest font in range
LyXFont::FONT_SIZE HighestFontInRange(size_type startpos,
size_type endpos) const;
/* If I set a PExtra Indent on one paragraph of a ENV_LIST-TYPE
I have to set it on each of it's elements */
///
- void SetPExtraType(BufferParams const &,
- int type, char const * width, char const * widthp);
+ void SetPExtraType(BufferParams const &, int type,
+ string const & width, string const & widthp);
///
void UnsetPExtraType(BufferParams const &);
///
InsetText * inset_owner;
///
- LyXFont GetFont(Buffer const *, LyXParagraph * par,
+ LyXFont const GetFont(Buffer const *, LyXParagraph * par,
LyXParagraph::size_type pos) const;
///
void SetCharFont(Buffer const *, LyXParagraph * par,
///
void ClearSelection() const;
///
- string selectionAsString(Buffer const *) const;
+ string const selectionAsString(Buffer const *) const;
/// just selects the word the cursor is in
void SelectWord(BufferView *);
to the beginning of this word.
With SelectSelectedWord can this be highlighted really
*/
- char * SelectNextWord(BufferView *, float & value);
+ string const SelectNextWord(BufferView *, float & value) const;
///
void SelectSelectedWord(BufferView *);
///
bool noindent);
///
void SetParagraphExtraOpt(BufferView *, int type,
- char const * width,
- char const * widthp,
+ string const & width,
+ string const & widthp,
int alignment, bool hfill,
bool start_minipage);
*/
bool IsStringInText(LyXParagraph * par,
LyXParagraph::size_type pos,
- char const * str) const;
+ string const & str) const;
/** sets the selection over the number of characters of string,
no check!!
*/
- void SetSelectionOverString(BufferView *, char const * str);
+ void SetSelectionOverString(BufferView *, string const & str);
/** simple replacing. The font of the first selected character
is used
*/
- void ReplaceSelectionWithString(BufferView *, char const * str);
+ void ReplaceSelectionWithString(BufferView *, string const & str);
/** if the string can be found: return true and set the cursor to
the new position */
- bool SearchForward(BufferView *, char const * str) const;
+ bool SearchForward(BufferView *, string const & str) const;
///
- bool SearchBackward(BufferView *, char const * str) const;
+ bool SearchBackward(BufferView *, string const & str) const;
/// needed to insert the selection
void InsertStringA(BufferView *, string const & str);
~LyxArrayBase();
/// Constructs a new array with dx elements starting at pos
- LyxArrayBase & operator= (LyxArrayBase const &);
+ LyxArrayBase & operator=(LyxArrayBase const &);
///
int empty() const { return (last == 0); }
}
inline
-LyxArrayBase::LyxArrayBase(const LyxArrayBase& a)
+LyxArrayBase::LyxArrayBase(LyxArrayBase const & a)
{
maxsize = a.maxsize;
bf = new byte[maxsize];
}
inline
-LyxArrayBase& LyxArrayBase::operator= (const LyxArrayBase& a)
+LyxArrayBase & LyxArrayBase::operator=(LyxArrayBase const & a)
{
if (this != &a) {
Resize(a.maxsize);
bool LyxArrayBase::Move(int p, int shift)
{
bool result = false;
- if (p<= last) {
- if (last+shift>= maxsize) {
+ if (p <= last) {
+ if (last + shift >= maxsize) {
Resize(last + shift);
}
- memmove(&bf[p+shift], &bf[p], last-p);
+ memmove(&bf[p + shift], &bf[p], last - p);
last += shift;
bf[last] = 0;
result = true;
inline
void LyxArrayBase::Remove(int pos, int dx)
{
- Move(pos+dx, -dx);
+ Move(pos + dx, -dx);
}
inline
-void LyxArrayBase::Merge(LyxArrayBase *a, int p, int dx)
+void LyxArrayBase::Merge(LyxArrayBase * a, int p, int dx)
{
Move(p, dx);
memcpy(&bf[p], &a->bf[0], dx);
}
inline
-void LyxArrayBase::MergeF(LyxArrayBase *a, int p, int dx)
+void LyxArrayBase::MergeF(LyxArrayBase * a, int p, int dx)
{
memcpy(&bf[p], &a->bf[0], dx);
}
inline
-void LyxArrayBase::Copy(void *a, int p, int dx)
+void LyxArrayBase::Copy(void * a, int p, int dx)
{
memcpy(&bf[p], a, dx);
}
inline
-LyxArrayBase *LyxArrayBase::Extract(int, int dx)
+LyxArrayBase * LyxArrayBase::Extract(int, int dx)
{
- LyxArrayBase *a = new LyxArrayBase(dx);
+ LyxArrayBase * a = new LyxArrayBase(dx);
a->Merge(this, 0, dx);
return a;
}
inline
void LyxArrayBase::Insert(int pos, byte c)
{
- if (pos<0) pos = last;
- if (pos>= maxsize)
- Resize(maxsize+ARRAY_STEP);
+ if (pos < 0) pos = last;
+ if (pos >= maxsize)
+ Resize(maxsize + ARRAY_STEP);
bf[pos] = c;
- if (pos>= last)
- last = pos+1;
+ if (pos >= last)
+ last = pos + 1;
}
#include <config.h>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
using std::istringstream;
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#ifdef __GNUG__
#pragma implementation "formula.h"
return lyxfont::width(reinterpret_cast<char const *>(s), ls, f);
}
+int mathed_string_width(short type, int size, string const & str)
+{
+ return mathed_string_width(type, size, reinterpret_cast<unsigned char const *>(str.c_str()), str.length());
+}
+
int mathed_char_width(short type, int size, byte c)
{
}
+int mathed_string_height(short type, int size, string const & str,
+ int & asc, int & des)
+{
+ return mathed_string_height(type, size,
+ reinterpret_cast<unsigned char const *>(str.c_str()), str.length(),
+ asc, des);
+}
+
+
int mathed_char_height(short type, int size, byte c, int & asc, int & des)
{
LyXFont font = WhichFont(type, size);
- asc = des = 0;
des = lyxfont::descent(c, font);
asc = lyxfont::ascent(c, font);
return asc + des;
} else {
st = string(reinterpret_cast<char const *>(s), ls);
}
- LyXFont mf = mathed_get_font(type, siz);
+ LyXFont const mf = mathed_get_font(type, siz);
pain.text(x, y, st, mf);
}
y = baseline + crow->getBaseline();
if (crow->isNumbered()) {
string str;
- if (crow->getLabel())
+ if (!crow->getLabel().empty())
str = string("(") + crow->getLabel() + ")";
else
str = "(#)";
}
-char const * InsetFormula::EditMessage() const
+string const InsetFormula::EditMessage() const
{
return _("Math editor mode");
}
// Now a symbol can be inserted only if the inset is locked
-void InsetFormula::InsertSymbol(BufferView * bv, char const * s)
+void InsetFormula::InsertSymbol(BufferView * bv, string const & s)
{
- if (!s || !mathcursor) return;
+ if (s.empty() || !mathcursor) return;
mathcursor->Interpret(s);
UpdateLocal(bv);
}
-void InsetFormula::GetCursorPos(BufferView *, int& x, int& y) const
+void InsetFormula::GetCursorPos(BufferView *, int & x, int & y) const
{
mathcursor->GetPos(x, y);
x -= par->xo;
y -= par->yo;
}
+
void InsetFormula::ToggleInsetCursor(BufferView * bv)
{
if (!mathcursor)
}
-vector<string> InsetFormula::getLabelList() const
+vector<string> const InsetFormula::getLabelList() const
{
//#warning This is dirty, I know. Ill clean it at 0.11
// Correction, the only way to clean this is with a new kernel: 0.13.
MathMatrixInset * mt = static_cast<MathMatrixInset*>(par);
MathedRowSt const * crow = mt->getRowSt();
while (crow) {
- if (crow->getLabel())
+ if (!crow->getLabel().empty())
label_list.push_back(crow->getLabel());
crow = crow->getNext();
}
case LFUN_SETXY:
{
int x, y, x1, y1;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
istringstream ist(arg.c_str());
-#else
- istrstream ist(arg.c_str());
-#endif
+//#else
+// istrstream ist(arg.c_str());
+//#endif
ist >> x >> y;
par->GetXY(x1, y1);
mathcursor->SetPos(x1 + x, y1 + y);
void
MathFuncInset::draw(Painter & pain, int x, int y)
{
- if (name && name[0] > ' ') {
+ if (!name.empty() && name[0] > ' ') {
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
font.setLatex(LyXFont::ON);
x += (lyxfont::width('I', font) + 3) / 4;
void MathFuncInset::Metrics()
{
- ln = (name) ? strlen(name): 0;
+ //ln = (name) ? strlen(name): 0;
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
font.setLatex(LyXFont::ON);
- width = lyxfont::width(name, ln, font)
+ width = lyxfont::width(name, font)
+ lyxfont::width('I', font) / 2;
- mathed_string_height(LM_TC_TEXTRM, size,
- reinterpret_cast<unsigned char const *>(name),
- strlen(name), ascent, descent);
+ mathed_string_height(LM_TC_TEXTRM, size, name, ascent, descent);
}
if(it.IsActive()) {
MathParInset * p = it.GetActiveInset();
if (!features.binom && p->GetType() == LM_OT_MACRO &&
- strcmp(p->GetName(), "binom") == 0) {
+ p->GetName() == "binom") {
features.binom = true;
} else {
for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
}
} else {
MathedInset* p = it.GetInset();
- if (!features.boldsymbol && p->GetName() &&
- strcmp(p->GetName(), "boldsymbol") == 0) {
+ if (!features.boldsymbol &&
+ p->GetName() == "boldsymbol") {
features.boldsymbol = true;
}
}
///
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
///
- LyXFont ConvertFont(LyXFont const & f) const {
+ LyXFont const ConvertFont(LyXFont const & f) const {
// We have already discussed what was here
LyXFont font(f);
font.setLatex(LyXFont::OFF);
}
/// what appears in the minibuffer when opening
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int x, int y, unsigned int button);
///
virtual RESULT LocalDispatch(BufferView *, int, string const &);
///
- void InsertSymbol(BufferView *, char const *);
+ void InsertSymbol(BufferView *, string const &);
///
bool SetNumber(bool);
///
- std::vector<string> getLabelList() const;
+ std::vector<string> const getLabelList() const;
protected:
///
}
-char const * InsetFormulaMacro::EditMessage() const
+string const InsetFormulaMacro::EditMessage() const
{
return _("Math macro editor mode");
}
Inset * Clone() const;
/// what appears in the minibuffer when opening
- char const * EditMessage() const;
+ string const EditMessage() const;
///
void Edit(BufferView *, int x, int y, unsigned int button);
///
///
RESULT LocalDispatch(BufferView *, int, string const &);
-protected:
- ///
- //void UpdateLocal();
-
private:
///
bool opened;
using std::endl;
-inline
+static inline
bool IsAlpha(char c)
{
return ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z');
}
// This was very smaller, I'll change it later
-inline
+static inline
bool IsMacro(short tok, int id)
{
return (tok != LM_TK_STACK && tok != LM_TK_FRAC && tok != LM_TK_SQRT
// Yes, mathed isn't using string yet.
-inline
+static inline
char * strnew(char const * s)
{
char * s1 = new char[strlen(s)+1];
-#define MAX_STACK_ITEMS 32
+static int const MAX_STACK_ITEMS = 32;
+
struct MathStackXIter {
}
-void MathedCursor::setLabel(char const * label)
+void MathedCursor::setLabel(string const & label)
{ // ugly hack and possible bug
- if (!cursor->setLabel(strnew(label)))
+ if (!cursor->setLabel(label))
lyxerr << "MathErr: Bad place to set labels." << endl;
}
}
-void MathedCursor::Interpret(char const * s)
+void MathedCursor::Interpret(string const & s)
{
MathedInset * p = 0;
- latexkeys * l = 0;
+ latexkeys * l = 0;
MathedTextCodes tcode = LM_TC_INSET;
if (s[0] == '^' || s[0] == '_') {
Insert(p);
return;
} else
- l = in_word_set (s, strlen(s));
+ l = in_word_set(s);
if (!l) {
p = MathMacroTable::mathMTable.getMacro(s);
if (!p) {
lyxerr[Debug::MATHED] << "Macro2 " << s << ' ' << tcode << endl;
- if (strcmp("root", s) == 0) {
+ if (s == "root") {
p = new MathRootInset();
tcode = LM_TC_ACTIVE_INSET;
} else
///
void SetPar(MathParInset *);
///
- void Interpret(char const *);
+ void Interpret(string const &);
///
void SetSize(short);
///
void setNumbered();
- void setLabel(char const *);
+ ///
+ void setLabel(string const &);
///
bool Limits();
/// Set accent: if argument = 0 it's considered consumed
class MathedInset {
public:
/// A math inset has a name (usually its LaTeX name), type and font-size
- MathedInset(char const * nm, short ot, short st);
+ MathedInset(string const & nm, short ot, short st);
///
explicit
MathedInset(MathedInset *);
virtual void SetLimits(bool) {}
///
- char const * GetName() const { return name; }
+ string const & GetName() const { return name; }
///
short GetType() const { return objtype; }
///
///
virtual void SetStyle(short st) { size = st; } // Metrics();
///
- virtual void SetName(char const * n) { name = n; }
+ virtual void SetName(string const & n) { name = n; }
protected:
///
- char const * name;
+ string name;
///
short objtype;
///
class MathParInset: public MathedInset {
public:
///
- MathParInset(short st = LM_ST_TEXT, char const * nm = 0,
+ MathParInset(short st = LM_ST_TEXT, string const & nm = string(),
short ot = LM_OT_MIN);
///
explicit
// Tab stuff used by Matrix.
///
- virtual void SetAlign(char, char const *) {}
-// ///
-// virtual int GetTabPos() { return 0; }
-// ///
-// virtual int GetTab(int) { return 0; }
+ virtual void SetAlign(char, string const &) {}
///
virtual int GetColumns() { return 1; }
///
virtual int GetRows() { return 1; }
///
virtual bool isMatrix() { return false; }
-// /// These functions should report an error
-// virtual char const* GetLabel() { return 0; }
-// virtual char const* GetLabel(int) { return 0; }
-
// Vertical switching
///
virtual bool setArgumentIdx(int i) { return (i == 0); }
virtual int getArgumentIdx() { return 0; }
///
virtual int getMaxArgumentIdx() { return 0; }
-// ///
-// virtual void SetLabel(char const *) {}
///
virtual void SetStyle(short);
///
for (int i = 0 ; i < n + 1 ; ++i)
w[i] = 0;
next = 0;
- label = 0;
+ //label = 0;
numbered = true;
}
///
~MathedRowSt() {
delete[] w;
- delete[] label;
+ //delete[] label;
}
/// Should be const but...
MathedRowSt * getNext() const { return next; }
/// ...we couldn't use this.
void setNext(MathedRowSt * n) { next = n; }
///
- char const * getLabel() const { return label; }
+ string const & getLabel() const { return label; }
///
bool isNumbered() const { return numbered; }
///
///
int getTab(int i) { return w[i]; }
///
- void setLabel(char * l) { label = l; }
+ void setLabel(string const & l) { label = l; }
///
void setNumbered(bool nf) { numbered = nf; }
///
/// widths
int * w;
///
- char * label;
+ string label;
///
bool numbered;
///
*vv = v_align;
return h_align;
}
-// ///
-// int GetTab(int);
///
int GetColumns() { return nc; }
///
/// tab sizes
int * ws;
///
- char v_align; // add approp. signedness
+ char v_align; // add approp. type
///
char * h_align;
/// Vertical structure
MathParInset ** mt);
///
void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
- char const * label = 0);
+ string const & label = string());
///
void mathed_parser_file(std::istream &, int);
inline
-MathedInset::MathedInset(char const * nm, short ot, short st):
+MathedInset::MathedInset(string const & nm, short ot, short st):
name(nm), objtype(ot), size(st)
{
width = ascent = descent = 0;
using std::endl;
-extern LyXFont mathed_get_font(short type, int size);
+extern LyXFont const mathed_get_font(short type, int size);
extern int mathed_char_width(short type, int style, byte c);
-extern int mathed_string_width(short type, int style, byte const* s, int ls);
-extern int mathed_string_height(short, int, byte const*, int, int&, int&);
-extern int mathed_char_height(short, int, byte, int&, int&);
+extern int mathed_string_width(short type, int style, string const &);
+extern int mathed_string_height(short, int, string const &, int &, int &);
+extern int mathed_char_height(short, int, byte, int &, int &);
void
MathSpaceInset::draw(Painter & pain, int x, int y)
void
MathParInset::Metrics()
{
- byte cx, cxp= 0, *s;
+ byte cx;
+ byte cxp = 0;
+ string s;
int ls;
- int asc= df_asc, des= 0;
- int tb = 0, tab= 0;
+ int asc = df_asc;
+ int des = 0;
+ int tb = 0;
+ int tab = 0;
bool limits = false;
while (data.OK()) {
cx = data.GetChar();
if (cx >= ' ') {
- s = data.GetString(ls);
- mathed_string_height(data.FCode(), size, s, ls, asc, des);
+ s = reinterpret_cast<char *>(data.GetString(ls));
+ mathed_string_height(data.FCode(), size, s, asc, des);
if (asc > ascent) ascent = asc;
if (des > descent) descent = des;
limits = false;
mathed_char_height(LM_TC_CONST, size, 'y', asc, des);
} else
if (MathIsInset(cx)) {
- MathedInset *p = data.GetInset();
+ MathedInset * p = data.GetInset();
p->SetStyle(size);
p->Metrics();
if (cx == LM_TC_UP) {
- asc += (limits) ? p->Height()+4: p->Ascent() +
- ((p->Descent()>asc) ? p->Descent()-asc+4: 0);
+ asc += (limits) ? p->Height() + 4: p->Ascent() +
+ ((p->Descent()>asc) ? p->Descent() - asc + 4: 0);
} else
if (cx == LM_TC_DOWN) {
- des += ((limits) ? p->Height()+4: p->Height()-p->Ascent()/2);
+ des += ((limits) ? p->Height() + 4: p->Height() - p->Ascent() / 2);
} else {
asc = p->Ascent();
des = p->Descent();
data.Next();
} else
if (cx == LM_TC_CR) {
- if (tb>0) {
+ if (tb > 0) {
int x, y;
data.GetIncPos(x, y);
if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) {
if (ascent<df_asc) ascent = df_asc;
tb = x;
}
- data.setTab(x-tb, tab);
+ data.setTab(x - tb, tab);
} else //if (GetColumns() == 1)
{
int x, y;
data.setTab(x, tab);
if (ascent<df_asc) ascent = df_asc;
}
- tb= tab= 0;
+ tb = tab = 0;
data.subMetrics(ascent, descent);
ascent = df_asc;
descent = 0;
data.Next();
- }
- else {
+ } else {
lyxerr << "Mathed Error: Unrecognized code[" << cx
<< "]" << endl;
break;
if (ascent<df_asc) ascent = df_asc;
data.setTab(0, tab);
} else {
- data.setTab(width-tb, tab);
+ data.setTab(width - tb, tab);
}
}
void
MathBigopInset::draw(Painter & pain, int x, int y)
{
- int ls;
- char c;
- char const *s;
+ string s;
short t;
if (sym < 256 || sym == LM_oint) {
- ls = 1;
- c = (sym == LM_oint) ? LM_int : sym;
- s = &c;
+ s += (sym == LM_oint) ? LM_int : sym;
t = LM_TC_BSYM;
} else {
s = name;
- ls = strlen(name);
t = LM_TC_TEXTRM;
}
if (sym == LM_oint) {
LColor::mathline);
++x;
}
- pain.text(x, y, s, ls, mathed_get_font(t, size));
+ pain.text(x, y, s, mathed_get_font(t, size));
}
void
MathBigopInset::Metrics()
{
- int ls;
char c;
- char const *s;
+ string s;
short t;
if (sym < 256 || sym == LM_oint) {
- ls = 1;
c = (sym == LM_oint) ? LM_int: sym;
- s = &c;
+ s += c;
t = LM_TC_BSYM;
} else {
s = name;
- ls = strlen(name);
t = LM_TC_TEXTRM;
}
- mathed_string_height(t, size,
- reinterpret_cast<const unsigned char*>(s),
- ls, ascent, descent);
- width = mathed_string_width(t, size,
- reinterpret_cast<const unsigned char*>(s),
- ls);
+ mathed_string_height(t, size, s, ascent, descent);
+ width = mathed_string_width(t, size, s);
if (sym == LM_oint) width += 2;
}
276,
};
-struct latexkeys *
+
+latexkeys *
in_word_set (register char const *str, register int len)
{
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- {
- register int key = math_hash (str, len);
-
- if (key <= MAX_HASH_VALUE && key >= 0)
- {
- register int idx = lookup[key];
-
- if (idx >= 0 && idx < MAX_HASH_VALUE)
- {
- register char const * s = wordlist[idx].name;
+ if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
+ int key = math_hash (str, len);
+
+ if (key <= MAX_HASH_VALUE && key >= 0) {
+ int idx = lookup[key];
+
+ if (idx >= 0 && idx < MAX_HASH_VALUE) {
+ char const * s = wordlist[idx].name;
+
+ if (*s == *str && !strcmp (str + 1, s + 1))
+ return &wordlist[idx];
+ } else if (idx < 0 && idx >= -MAX_HASH_VALUE) {
+ return 0;
+ } else {
+ int offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
+ latexkeys * base = &wordlist[-lookup[offset]];
+ latexkeys * ptr = base + -lookup[offset + 1];
+
+ while (--ptr >= base)
+ if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1))
+ return ptr;
+ }
+ }
+ }
+ return 0;
+}
- if (*s == *str && !strcmp (str + 1, s + 1))
- return &wordlist[idx];
- }
- else if (idx < 0 && idx >= -MAX_HASH_VALUE)
- return 0;
- else
- {
- register int offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
- register struct latexkeys *base = &wordlist[-lookup[offset]];
- register struct latexkeys *ptr = base + -lookup[offset + 1];
- while (--ptr >= base)
- if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1))
- return ptr;
- }
- }
- }
- return 0;
+latexkeys * in_word_set(string const & str)
+{
+ return in_word_set(str.c_str(), str.length());
}
+
latexkeys *lm_get_key_by_id(int t, short tk)
{
- latexkeys* l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
- latexkeys* base = &wordlist[MIN_HASH_VALUE];
+ latexkeys * l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
+ latexkeys * base = &wordlist[MIN_HASH_VALUE];
while (--l >= base) {
if (t == l->id && tk == l->token)
return l;
return 0;
}
+
latexkeys *lm_get_key_by_index(int i)
{
- if (i>0 && i<TOTAL_KEYWORDS+2)
+ if (i > 0 && i < TOTAL_KEYWORDS + 2)
return &wordlist[i];
else
return 0;
#include "symbol_def.h"
-inline
+static inline
char * strnew(char const * s)
{
char * s1 = new char[strlen(s)+1];
objtype = LM_OT_UNDEF;
size = LM_ST_TEXT;
width = ascent = descent = 0;
- name = 0;
+ //name = 0;
}
}
-MathFuncInset::MathFuncInset(char const * nm, short ot, short st)
+MathFuncInset::MathFuncInset(string const & nm, short ot, short st)
: MathedInset("", ot, st)
{
ln = 0;
lims = (GetType() == LM_OT_FUNCLIM);
if (GetType() == LM_OT_UNDEF) {
- fname = strnew(nm);
+ fname = nm;
SetName(fname);
} else {
- fname = 0;
+ //fname = 0;
SetName(nm);
}
}
}
-MathParInset::MathParInset(short st, char const * nm, short ot)
+MathParInset::MathParInset(short st, string const & nm, short ot)
: MathedInset(nm, ot, st)
{
array = 0;
while (mrow) {
r = new MathedRowSt(nc + 1);
r->numbered = mrow->numbered;
- if (mrow->label)
- r->label = strnew(mrow->label);
+ //if (mrow->label)
+ r->label = mrow->label;
if (!ro)
row = r;
else
}
-MathBigopInset::MathBigopInset(char const* nam, int id, short st)
+MathBigopInset::MathBigopInset(string const & nam, int id, short st)
: MathedInset(nam, LM_OT_BIGOP, st), sym(id)
{
lims = -1;
}
-MathDotsInset::MathDotsInset(char const * nam, int id, short st)
+MathDotsInset::MathDotsInset(string const & nam, int id, short st)
: MathedInset(nam, LM_OT_DOTS, st), code(id) {}
public:
///
explicit
- MathFuncInset(char const * nm,
+ MathFuncInset(string const & nm,
short ot = LM_OT_FUNC, short st = LM_ST_TEXT);
///
~MathFuncInset();
///
bool lims;
///
- char * fname;
+ string fname;
};
class MathDotsInset: public MathedInset {
public:
///
- MathDotsInset(char const *, int, short st = LM_ST_TEXT);
+ MathDotsInset(string const &, int, short st = LM_ST_TEXT);
///
MathedInset * Clone();
///
class MathBigopInset: public MathedInset {
public:
///
- MathBigopInset(char const *, int, short st = LM_ST_TEXT);
+ MathBigopInset(string const &, int, short st = LM_ST_TEXT);
///
MathedInset * Clone();
///
inline
MathFuncInset::~MathFuncInset()
-{
- if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
-}
+{}
inline
// the builtin memcpy() is broken in egcs and gcc 2.95.x on alpha
// stations. We provide a hand-made version instead.
-inline
+static inline
void my_memcpy( void * ps_in, const void * pt_in, size_t n )
{
char * ps = static_cast<char *>(ps_in);
}
-byte MathedIter::GetChar()
+byte MathedIter::GetChar() const
{
if (IsFont()) {
fcode = array->bf[pos];
}
-byte* MathedIter::GetString(int& len)
+byte * MathedIter::GetString(int& len) const
{
if (IsFont()) {
fcode = array->bf[++pos];
- pos++;
+ ++pos;
}
- byte *s = &array->bf[pos];
+ byte * s = &array->bf[pos];
len = pos;
- while (array->bf[pos]>= ' ' && pos<array->last) pos++;
- len = pos-len;
+ while (array->bf[pos] >= ' ' && pos < array->last) ++pos;
+ len = pos - len;
return s;
}
-MathedInset* MathedIter::GetInset()
+string const MathedIter::GetString() const
+{
+ int ls = 0;
+ byte * s = GetString(ls);
+ return string(reinterpret_cast<char *>(s), ls);
+}
+
+
+MathedInset * MathedIter::GetInset() const
{
if (IsInset()) {
- MathedInset* p;
- my_memcpy(&p, &array->bf[pos+1], sizeof(p));
+ MathedInset * p;
+ my_memcpy(&p, &array->bf[pos + 1], sizeof(p));
return p;
} else {
lyxerr << "Math Error: This is not an inset["
// An active math inset MUST be derived from MathParInset because it
// must have at least one paragraph to edit
-MathParInset * MathedIter::GetActiveInset()
+MathParInset * MathedIter::GetActiveInset() const
{
if (IsActive()) {
return static_cast<MathParInset*>(GetInset());
Reset();
}
-byte* MathedXIter::GetString(int& ls)
+
+byte * MathedXIter::GetString(int & ls) const
{
static byte s[255];
- byte const *sxs = MathedIter::GetString(ls);
- if (ls>0) {
- strncpy(reinterpret_cast<char*>(s), reinterpret_cast<const char*>(sxs), ls);
+ byte const * sxs = MathedIter::GetString(ls);
+ if (ls > 0) {
+ strncpy(reinterpret_cast<char*>(s),
+ reinterpret_cast<const char*>(sxs), ls);
x += mathed_string_width(fcode, size, s, ls);
return &s[0];
}
}
+string const MathedXIter::GetString() const
+{
+ int ls;
+ byte * s = GetString(ls);
+ return string(reinterpret_cast<char*>(s), ls);
+}
+
+
bool MathedXIter::Next()
{
// lyxerr << "Ne[" << pos << "]";
}
-bool MathedXIter::setLabel(char* label)
+bool MathedXIter::setLabel(string const & label)
{
- if (label && crow) {
+ if (!label.empty() && crow) {
crow->setLabel(label);
return true;
}
}
-MathedRowSt *MathedXIter::adjustVerticalSt()
+MathedRowSt * MathedXIter::adjustVerticalSt()
{
GoBegin();
if (!crow) {
// lyxerr << " CRW" << ncols << " ";
- crow = new MathedRowSt(ncols+1); // this leaks
+ crow = new MathedRowSt(ncols + 1); // this leaks
}
// lyxerr<< " CRW[" << crow << "] ";
- MathedRowSt *mrow = crow;
+ MathedRowSt * mrow = crow;
while (OK()) {
if (IsCR()) {
- if (col>= ncols) ncols = col+1;
- MathedRowSt *r = new MathedRowSt(ncols+1); // this leaks
+ if (col >= ncols) ncols = col + 1;
+ MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
// r->next = crow->next;
crow->next = r;
crow = r;
///
void goPosAbs(int);
///
- int Empty() { return array->Last()<= 1; }
+ int Empty() const { return array->Last()<= 1; }
///
- int OK() { return array && (pos < array->Last()); }
+ int OK() const { return array && (pos < array->Last()); }
///
- int IsFirst() { return (pos == 0); }
+ int IsFirst() const { return (pos == 0); }
///
- byte GetChar();
+ byte GetChar() const;
///
- byte * GetString(int& len);
+ byte * GetString(int & len) const;
///
- MathedInset * GetInset();
+ string const GetString() const;
///
- MathParInset * GetActiveInset();
+ MathedInset * GetInset() const;
///
- bool IsInset();
+ MathParInset * GetActiveInset() const;
///
- bool IsActive();
+ bool IsInset() const;
///
- bool IsFont();
+ bool IsActive() const;
///
- bool IsScript();
+ bool IsFont() const;
///
- bool IsTab();
+ bool IsScript() const;
///
- bool IsCR();
+ bool IsTab() const;
+ ///
+ bool IsCR() const;
///
virtual void Reset();
///
///
void SetData(LyxArrayBase * a) { array = a; Reset(); }
///
- LyxArrayBase * GetData() { return array; }
+ LyxArrayBase * GetData() const { return array; }
/// Copy every object from position p1 to p2
- LyxArrayBase * Copy(int p1= 0, int p2= 10000);
+ LyxArrayBase * Copy(int p1 = 0, int p2 = 10000);
/// Delete every object from position p1 to p2
void Clear();
///
int flags;
///
- short fcode;
+ mutable short fcode;
///
- int pos;
+ mutable int pos;
///
int row, col, ncols;
///
- LyxArrayBase *array;
+ LyxArrayBase * array;
// one element stack
struct MIState {
///
///
void SetData(MathParInset *);
///
- MathParInset * getPar() { return p; }
+ MathParInset * getPar() const { return p; }
///
bool Next();
///
void Adjust();
///
inline
- void GetPos(int &, int &);
+ void GetPos(int &, int &) const;
///
inline
- void GetIncPos(int &, int &);
+ void GetIncPos(int &, int &) const;
+ ///
+ byte * GetString(int &) const ;
///
- byte * GetString(int &);
+ string const GetString() const;
///
- int GetX();
+ int GetX() const;
///
- int GetY();
+ int GetY() const;
///
void subMetrics(int, int);
///
void fitCoord(int, int);
///
- void getAD(int & a, int & d);
+ void getAD(int & a, int & d) const;
/// Create a new row and insert #ncols# tabs.
void addRow();
void delRow();
///
- bool setLabel(char* label);
+ bool setLabel(string const & label);
///
bool setNumbered(bool);
///
void setTab(int, int);
/// Merge the array at current position
- void Merge(LyxArrayBase*);
+ void Merge(LyxArrayBase *);
/// Delete every object from current position to pos2
void Clean(int pos2);
- MathedRowSt *adjustVerticalSt();
+ ///
+ MathedRowSt * adjustVerticalSt();
private:
/// This function is not recursive, as MathPar::Metrics is
- void IMetrics(int, int&, int&, int&);
+ void IMetrics(int, int &, int &, int &);
/// Font size (display, text, script, script2)
int size;
/// current position
- int x, y;
-// /// max ascent and descent
-// int asc, des;
- ///
- MathParInset *p;
+ mutable int x;
+ ///
+ int y;
+ ///
+ MathParInset * p;
// Limits auxiliary variables
/// Position and max width of a script
protected:
///
- MathedRowSt *crow;
+ MathedRowSt * crow;
private:
///
inline
-bool MathedIter::IsInset()
+bool MathedIter::IsInset() const
{
return MathIsInset((*array)[pos]);
}
inline
-bool MathedIter::IsActive()
+bool MathedIter::IsActive() const
{
return MathIsActive((*array)[pos]);
}
inline
-bool MathedIter::IsFont()
+bool MathedIter::IsFont() const
{
return MathIsFont((*array)[pos]);
}
inline
-bool MathedIter::IsScript()
+bool MathedIter::IsScript() const
{
return MathIsScript((*array)[pos]);
}
inline
-bool MathedIter::IsTab()
+bool MathedIter::IsTab() const
{
return ((*array)[pos] == LM_TC_TAB);
}
inline
-bool MathedIter::IsCR()
+bool MathedIter::IsCR() const
{
return ((*array)[pos] == LM_TC_CR);
}
inline
-MathedIter::MathedIter(LyxArrayBase * d): array(d)
+MathedIter::MathedIter(LyxArrayBase * d)
+ : array(d)
{
pos = 0;
row = col = 0;
inline
-void MathedXIter::GetPos(int&xx, int& yy)
+void MathedXIter::GetPos(int & xx, int & yy) const
{
if (p)
p->GetXY(xx, yy);
}
inline
-int MathedXIter::GetX()
+int MathedXIter::GetX() const
{
int xx, yy;
GetPos(xx, yy);
}
inline
-int MathedXIter::GetY()
+int MathedXIter::GetY() const
{
int xx, yy;
GetPos(xx, yy);
inline
-void MathedXIter::GetIncPos(int& xx, int& yy)
+void MathedXIter::GetIncPos(int & xx, int & yy) const
{
xx = x; yy = y;
}
inline
-void MathedXIter::getAD(int& a, int& d)
+void MathedXIter::getAD(int & a, int & d) const
{
if (crow) {
a = crow->asc;
if (expnd_mode) {
MathParInset::draw(pain, x, baseline);
} else {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
ost << '#' << number;
drawStr(pain, LM_TC_TEX, size, x, baseline,
reinterpret_cast<byte const *>(ost.str().c_str()), 2);
-#else
- char s[3];
- ostrstream ost(s, 3);
- ost << '#' << number << '\0';
- drawStr(pain, LM_TC_TEX, size, x, baseline,
- reinterpret_cast<byte *>(ost.str()), 2);
-#endif
+//#else
+// char s[3];
+// ostrstream ost(s, 3);
+// ost << '#' << number << '\0';
+// drawStr(pain, LM_TC_TEX, size, x, baseline,
+// reinterpret_cast<byte *>(ost.str()), 2);
+//#endif
}
}
if (expnd_mode) {
MathParInset::Metrics();
} else {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
ost << '#' << number;
width = mathed_string_width(LM_TC_TEX, size,
mathed_string_height(LM_TC_TEX, size,
reinterpret_cast<byte const *>(ost.str().c_str()),
2, ascent, descent);
-#else
- char s[3];
- ostrstream ost(s, 3);
- ost << '#' << number << '\0';
- width = mathed_string_width(LM_TC_TEX, size,
- reinterpret_cast<byte *>
- (ost.str()), 2);
- mathed_string_height(LM_TC_TEX, size,
- reinterpret_cast<byte *>(ost.str()),
- 2, ascent, descent);
-#endif
+//#else
+// char s[3];
+// ostrstream ost(s, 3);
+// ost << '#' << number << '\0';
+// width = mathed_string_width(LM_TC_TEX, size,
+// reinterpret_cast<byte *>
+// (ost.str()), 2);
+// mathed_string_height(LM_TC_TEX, size,
+// reinterpret_cast<byte *>(ost.str()),
+// 2, ascent, descent);
+//#endif
}
}
// The search is currently linear but will be binary or hash, later.
-MathMacroTemplate * MathMacroTable::getTemplate(char const * name) const
+MathMacroTemplate * MathMacroTable::getTemplate(string const & name) const
{
for (int i = 0; i < num_macros; ++i) {
- if (strcmp(name, macro_table[i]->GetName()) == 0)
+ if (name == macro_table[i]->GetName())
return macro_table[i];
}
///
void addTemplate(MathMacroTemplate *);
///
- MathMacro * getMacro(char const *) const;
+ MathMacro * getMacro(string const &) const;
///
- MathMacroTemplate * getTemplate(char const *) const;
+ MathMacroTemplate * getTemplate(string const &) const;
///
void builtinMacros();
///
inline
-MathMacro * MathMacroTable::getMacro(char const * name) const
+MathMacro * MathMacroTable::getMacro(string const & name) const
{
MathMacroTemplate * mt = getTemplate(name);
return (mt) ? new MathMacro(mt): 0;
#include <config.h>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#include FORMS_H_LOCATION
case MM_APPLY:
case MM_OK:
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
ost << delim_code[left] << ' ' << delim_code[right];
lyxfunc->Dispatch(LFUN_MATH_DELIM, ost.str().c_str());
-#else
- char s[80];
- ostrstream ost(s, 80);
- ost << delim_code[left] << ' ' << delim_code[right] << '\0';
- lyxfunc->Dispatch(LFUN_MATH_DELIM, ost.str());
-#endif
+//#else
+// char s[80];
+// ostrstream ost(s, 80);
+// ost << delim_code[left] << ' ' << delim_code[right] << '\0';
+// lyxfunc->Dispatch(LFUN_MATH_DELIM, ost.str());
+//#endif
if (data == MM_APPLY) break;
}
case MM_CLOSE: fl_hide_form(fd_delim->delim); break;
int nx = int(fl_get_slider_value(fd_matrix->columns)+0.5);
int ny = int(fl_get_slider_value(fd_matrix->rows)+0.5);
if (data == MM_OK) fl_hide_form(fd_matrix->matrix);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
ost << nx << ' ' << ny << ' ' << c << sh;
lyxfunc->Dispatch(LFUN_INSERT_MATRIX, ost.str().c_str());
-#else
- char s[80];
- ostrstream ost(s, 80);
- ost << nx << ' ' << ny << ' ' << c << sh << '\0';
- lyxfunc->Dispatch(LFUN_INSERT_MATRIX, ost.str());
-#endif
+//#else
+// char s[80];
+// ostrstream ost(s, 80);
+// ost << nx << ' ' << ny << ' ' << c << sh << '\0';
+// lyxfunc->Dispatch(LFUN_INSERT_MATRIX, ost.str());
+//#endif
break;
}
case MM_CLOSE: fl_hide_form(fd_matrix->matrix); break;
static istream * yyis;
static bool yy_mtextmode= false;
-inline
+static inline
char * strnew(char const * s)
{
char * s1 = new char[strlen(s) + 1]; // this leaks when not delete[]'ed
static
-void mathPrintError(char const * msg)
+void mathPrintError(string const & msg)
{
lyxerr << "Line ~" << yylineno << ": Math parse error: "
<< msg << endl;
#pragma interface
#endif
+#include "LString.h"
+
#include "symbol_def.h"
///
latexkeys *
in_word_set (register char const * str, register int len);
+///
+latexkeys * in_word_set(string const & str);
+
///
latexkeys * lm_get_key(int index);
}
FL_OBJECT *
-BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char const * data, Bool vert)
+BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh,
+ unsigned char const * data, Bool vert)
{
if (i >= nb)
return 0;
}
-void math_insert_symbol(char const * s)
+void math_insert_symbol(string const & s)
{
if (current_view->available()) {
if (!current_view->the_locking_inset) {
if (!crow->isNumbered()) {
os << "\\nonumber ";
}
- if (crow->getLabel()) {
+ if (!crow->getLabel().empty()) {
os << "\\label{"
<< crow->getLabel()
<< "} ";
if (!crow->isNumbered()) {
os << "\\nonumber ";
}
- if (crow->getLabel()) {
+ if (!crow->getLabel().empty()) {
os << "\\label{"
<< crow->getLabel()
<< "} ";
void mathed_write(MathParInset * p, ostream & os, int * newlines,
- bool fragile, char const * label)
+ bool fragile, string const & label)
{
number_of_newlines = 0;
short mathed_env = p->GetType();
++number_of_newlines;
}
- if (label && label[0] > ' ' && mathed_env == LM_EN_EQUATION){
+ if (!label.empty() && label[0] > ' ' && mathed_env == LM_EN_EQUATION){
os << "\\label{"
<< label
<< "}\n";
string const & = string(),
int delay_secs= 6);
///
- string GetText() const { return text; }
+ string const GetText() const { return text; }
///
void Init();
///
///
enum{ MAX_HISTORY = 10 };
///
- string history[MAX_HISTORY];
+ mutable string history[MAX_HISTORY];
///
- int history_idx, history_cnt;
+ mutable int history_idx;
+ ///
+ mutable int history_cnt;
///
- void addHistory(string const &cmd) {
+ void addHistory(string const &cmd) const {
if (history_cnt == 0
|| (history_cnt > 0
&& cmd != history[(history_cnt - 1) % MAX_HISTORY])) {
history_idx = history_cnt;
}
///
- string getHistory() { return history[history_idx % MAX_HISTORY]; }
+ string const getHistory() const { return history[history_idx % MAX_HISTORY]; }
};
#endif
// Gets uninstantiated font setting at position.
// Optimized after profiling. (Asger)
-LyXFont LyXParagraph::GetFontSettings(BufferParams const & bparams,
+LyXFont const LyXParagraph::GetFontSettings(BufferParams const & bparams,
LyXParagraph::size_type pos) const
{
#ifdef NEW_INSETS
}
// Gets uninstantiated font setting at position 0
-LyXFont LyXParagraph::GetFirstFontSettings() const
+LyXFont const LyXParagraph::GetFirstFontSettings() const
{
if (size() > 0) {
if (!fontlist.empty())
// the true picture of the buffer. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
-LyXFont LyXParagraph::getFont(BufferParams const & bparams,
+LyXFont const LyXParagraph::getFont(BufferParams const & bparams,
LyXParagraph::size_type pos) const
{
LyXFont tmpfont;
// return an string of the current word, and the end of the word in lastpos.
-string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
+string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
{
Assert(lastpos >= 0);
// the next two functions are for the manual labels
-string LyXParagraph::GetLabelWidthString() const
+string const LyXParagraph::GetLabelWidthString() const
{
#ifndef NEW_INSETS
if (!FirstPhysicalPar()->labelwidthstring.empty())
column = 0;
} else if (c == LyXParagraph::META_INSET) {
inset = GetInset(i);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
inset->DocBook(buffer, ost);
string tmp_out = ost.str().c_str();
-#else
- ostrstream ost;
- inset->DocBook(buffer, ost);
- ost << '\0';
- char * ctmp = ost.str();
- string tmp_out(ctmp);
- delete [] ctmp;
-#endif
+//#else
+// ostrstream ost;
+// inset->DocBook(buffer, ost);
+// ost << '\0';
+// char * ctmp = ost.str();
+// string tmp_out(ctmp);
+// delete [] ctmp;
+//#endif
//
// This code needs some explanation:
// Two insets are treated specially
}
if (c == LyXParagraph::META_INSET) {
inset = GetInset(i);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
inset->DocBook(buffer, ost);
string tmp_out = ost.str().c_str();
-#else
- ostrstream ost;
- inset->DocBook(buffer, ost);
- ost << '\0';
- char * ctmp = ost.str();
- string tmp_out(ctmp);
- delete [] ctmp;
-#endif
+//#else
+// ostrstream ost;
+// inset->DocBook(buffer, ost);
+// ost << '\0';
+// char * ctmp = ost.str();
+// string tmp_out(ctmp);
+// delete [] ctmp;
+//#endif
//
// This code needs some explanation:
// Two insets are treated specially
// process footnotes > depth 0 or in environments separately
// NOTE: Currently don't support footnotes within footnotes
// even though that is possible using the \footnotemark
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream dummy;
-#else
- ostrstream dummy;
-#endif
+//#else
+// ostrstream dummy;
+//#endif
TexRow dummy_texrow;
int dummy_count = 0;
do {
"Footnote in a Footnote -- not supported"
<< endl;
}
-#ifndef HAVE_OSTREAM
- delete [] dummy.str();
-#endif
+//#ifndef HAVE_OSTREAM
+// delete [] dummy.str();
+//#endif
}
switch (footnotekind) {
#endif
void LyXParagraph::SetPExtraType(BufferParams const & bparams,
- int type, char const * width,
- char const * widthp)
+ int type, string const & width,
+ string const & widthp)
{
pextra_type = type;
pextra_width = width;
// Convert the paragraph to a string.
// Used for building the table of contents
-string LyXParagraph::String(Buffer const * buffer, bool label)
+string const LyXParagraph::String(Buffer const * buffer, bool label)
{
BufferParams const & bparams = buffer->params;
string s;
s += c;
else if (c == META_INSET &&
GetInset(i)->LyxCode() == Inset::MATH_CODE) {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
GetInset(i)->Ascii(buffer, ost);
-#else
- ostrstream ost;
- GetInset(i)->Ascii(buffer, ost);
- ost << '\0';
-#endif
+//#else
+// ostrstream ost;
+// GetInset(i)->Ascii(buffer, ost);
+// ost << '\0';
+//#endif
s += subst(ost.str(),'\n',' ');
}
}
}
-string LyXParagraph::String(Buffer const * buffer,
+string const LyXParagraph::String(Buffer const * buffer,
LyXParagraph::size_type beg,
LyXParagraph::size_type end)
{
if (IsPrintable(c))
s += c;
else if (c == META_INSET) {
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ost;
GetInset(i)->Ascii(buffer, ost);
-#else
- ostrstream ost;
- GetInset(i)->Ascii(buffer, ost);
- ost << '\0';
-#endif
+//#else
+// ostrstream ost;
+// GetInset(i)->Ascii(buffer, ost);
+// ost << '\0';
+//#endif
s += ost.str();
}
#ifndef NEW_TABULAR
// Send word to ispell and get reply
static
-isp_result * sc_check_word(char *word)
+isp_result * sc_check_word(string const & word)
{
//Please rewrite to use string.
- isp_result *result;
- char buf[1024];
- fputs(word, out);
+ fputs(word.c_str(), out);
fputc('\n', out);
+ char buf[1024];
fgets(buf, 1024, in);
/* I think we have to check if ispell is still alive here because
the signal-handler could have disabled blocking on the fd */
- if (isp_pid == -1) return 0;
+ if (!sc_still_alive()) return 0;
- result = new isp_result;
+ isp_result * result = new isp_result;
switch (*buf) {
case '*': // Word found
static inline
-void sc_insert_word(char const *word)
+void sc_insert_word(string const & word)
{
fputc('*', out); // Insert word in personal dictionary
- fputs(word, out);
+ fputs(word.c_str(), out);
fputc('\n', out);
}
static inline
-void sc_accept_word(char const *word)
+void sc_accept_word(string const & word)
{
fputc('@', out); // Accept in this session
- fputs(word, out);
+ fputs(word.c_str(), out);
fputc('\n', out);
}
static inline
-void sc_store_replacement(char const *mis, string const & cor) {
+void sc_store_replacement(string const & mis, string const & cor) {
if(actual_spell_checker == ASC_ASPELL) {
fputs("$$ra ", out);
- fputs(mis, out);
+ fputs(mis.c_str(), out);
fputc(',', out);
fputs(cor.c_str(), out);
fputc('\n', out);
// Send word to ispell and get reply
static
-isp_result * sc_check_word(char *word)
+isp_result * sc_check_word(string const & word)
{
isp_result * result = new isp_result;
int word_ok = pspell_manager_check(sc, word);
- assert(word_ok != -1);
+ Assert(word_ok != -1);
if (word_ok) {
-
result->flag = ISP_OK;
-
} else {
- const PspellWordList * sugs = pspell_manager_suggest(sc, word);
- assert(sugs != 0);
+ PspellWordList const * sugs = pspell_manager_suggest(sc, word);
+ Assert(sugs != 0);
result->els = pspell_word_list_elements(sugs);
if (pspell_word_list_empty(sugs))
result->flag = ISP_UNKNOWN;
else
result->flag = ISP_MISSED;
-
}
return result;
}
pspell_manager_save_all_word_lists(sc);
}
+
static inline
-void sc_insert_word(char const *word)
+void sc_insert_word(string const & word)
{
pspell_manager_add_to_personal(sc, word);
}
static inline
-void sc_accept_word(char const *word)
+void sc_accept_word(string const & word)
{
pspell_manager_add_to_session(sc, word);
}
+
static inline
-void sc_store_replacement(char const *mis, string const & cor) {
- pspell_manager_store_replacement(sc, mis, cor.c_str());
+void sc_store_replacement(string const & mis, string const & cor)
+{
+ pspell_manager_store_replacement(sc, mis.c_str(), cor.c_str());
}
#endif
unsigned int word_count = 0;
while (true) {
- char * word = bv->nextWord(newval);
- if (word == 0) break;
+ string const word = bv->nextWord(newval);
+ if (word.empty()) break;
++word_count;
// Update slider if and only if value has changed
if (word_count%1000 == 0) {
obj = fl_check_forms();
if (obj == fd_form_spell_check->stop) {
- delete[] word;
close_spell_checker();
return true;
}
if (obj == fd_form_spell_check->done) {
- delete[] word;
close_spell_checker();
return false;
}
result = sc_check_word(word);
if (!sc_still_alive()) {
delete result;
- delete[] word;
break;
}
reverse(tmp.begin(),tmp.end());
fl_set_object_label(fd_form_spell_check->text, tmp.c_str());
} else
- fl_set_object_label(fd_form_spell_check->text, word);
- fl_set_input(fd_form_spell_check->input, word);
+ fl_set_object_label(fd_form_spell_check->text, word.c_str());
+ fl_set_input(fd_form_spell_check->input, word.c_str());
fl_clear_browser(fd_form_spell_check->browser);
const char * w;
while ((w = result->next_miss()) != 0) {
}
if (obj == fd_form_spell_check->stop) {
delete result;
- delete[] word;
close_spell_checker();
return true;
}
if (obj == fd_form_spell_check->done) {
delete result;
- delete[] word;
close_spell_checker();
return false;
}
}
default:
delete result;
- delete[] word;
}
}
path.h \
putenv.C \
rename.C \
+ sstream.h \
$(REGEX) syscall.C \
syscall.h \
syscontr.C \
#include <config.h>
-#include <stdio.h>
+#include <fstream>
+
+//#include <stdio.h>
#include "support/lyxlib.h"
#include "LString.h"
-#include "support/syscall.h"
+//#include "support/syscall.h"
#include "support/filetools.h"
-bool lyx::copy(char const * from, char const * to)
+bool lyx::copy(string const & from, string const & to)
{
+#if 0
string command = "cp " + QuoteName(from) + " " + QuoteName(to);
return Systemcalls().startscript(Systemcalls::System,
command) == 0;
+#else
+ ifstream ifs(from.c_str());
+ if (!ifs) return false;
+ ofstream ofs(to.c_str(), ios::out|ios::trunc);
+ if (!ofs) return false;
+ ofs << ifs.rdbuf();
+ if (ofs.good()) return true;
+ return false;
+#endif
}
#include <utility>
#include <fstream>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#ifdef __GNUG__
#pragma implementation "filetools.h"
FileInfo finfo(fname);
if (finfo.exist()) {
ifstream ifs(fname.c_str());
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ofs;
-#else
-#warning The rumour goes that this might leak, but who really cares?
- ostrstream ofs;
-#endif
+//#else
+//#warning The rumour goes that this might leak, but who really cares?
+// ostrstream ofs;
+//#endif
if (ifs && ofs) {
ofs << ifs.rdbuf();
ifs.close();
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
return ofs.str().c_str();
-#else
- ofs << '\0';
- char const * tmp = ofs.str();
- string ret(tmp);
- delete[] tmp;
- return ret;
-#endif
+//#else
+// ofs << '\0';
+// char const * tmp = ofs.str();
+// string ret(tmp);
+// delete[] tmp;
+// return ret;
+//#endif
}
}
lyxerr << "LyX was not able to read file '" << fname << "'" << endl;
return CleanupPath(oldname.substr(0, last_dot) + ext);
}
+
/// Return the extension of the file (not including the .)
-string GetExtension(string const & name)
+string const GetExtension(string const & name)
{
string::size_type last_slash = name.rfind('/');
string::size_type last_dot = name.rfind('.');
return string();
}
+
// Creates a nice compact path for displaying
string const
MakeDisplayPath (string const & path, unsigned int threshold)
return c.first != -1 ? strip(c.second, '\n') : string();
}
+
void removeAutosaveFile(string const & filename)
{
string a = OnlyPath(filename);
ChangeExtension(string const & oldname, string const & extension);
/// Return the extension of the file (not including the .)
-string GetExtension(string const & name);
+string const GetExtension(string const & name);
/// Create absolute path. If impossible, don't do anything
string const ExpandPath(string const & path);
#include "support/filetools.h"
#include "gettext.h"
-string lyx::getUserName()
+string const lyx::getUserName()
{
string userName(GetEnv("LOGNAME"));
if (userName.empty())
#include <cstring>
#include <cctype>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#include "LString.h"
inline
string const tostr(T const & t)
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream ostr;
ostr << t;
return ostr.str().c_str();
// We need to use the .c_str since we sometimes are using
// our own string class and that is not compatible with
// basic_string<char>. (of course we don't want this later)
-#else
+//#else
// The buf is probably a bit large, but if we want to be safer
// we should leave it this big. As compiler/libs gets updated
// this part of the code will cease to be used and we loose
// nothing.
- char buf[2048]; // a bit too large perhaps?
- ostrstream ostr(buf, sizeof(buf));
- ostr << t << '\0';
- return buf;
-#endif
+// char buf[2048]; // a bit too large perhaps?
+// ostrstream ostr(buf, sizeof(buf));
+// ostr << t << '\0';
+// return buf;
+//#endif
}
+
///
inline
string const tostr(bool b)
/// Returns false it it fails
bool rename(char const * from, char const * to);
/// Returns false it it fails
- bool copy(char const * from, char const * to);
+ bool copy(string const & from, string const & to);
/// generates a checksum
unsigned long sum(char const * file);
/// returns a date string (not used currently)
char * date();
/// returns the name of the user (not used currently)
- string getUserName();
+ string const getUserName();
///
int kill(long int pid, int sig);
///
/// Returns false it it fails
static bool rename(char const * from, char const * to);
/// Returns false it it fails
- static bool copy(char const * from, char const * to);
+ static bool copy(string const & from, string const & to);
/// generates a checksum
static unsigned long sum(char const * file);
/// returns a date string (not used currently)
static char * date();
/// returns the name of the user (not used currently)
- static string getUserName();
+ static string const getUserName();
///
static int kill(long int pid, int sig);
///
lyxstring & lyxstring::replace(size_type i, size_type n,
size_type n2, value_type c)
{
- Assert(i < rep->sz); // OURS!
+ Assert(i <= rep->sz); // OURS!
TestlyxstringInvariant(this);
rep = rep->get_own_copy();
#include <fstream>
+#if 0
#ifdef HAVE_SSTREAM
#include <sstream>
using std::ostringstream;
#else
#include <strstream>
#endif
+#else
+#include "Lsstream.h"
+#endif
#include "support/lyxlib.h"
ifstream ifs(file);
if (!ifs) return 0;
ifs.unsetf(ios::skipws);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
ostringstream ostr;
ostr << ifs.rdbuf();
// The .c_str() is here in case we use our lyxstring class
// instead of standard string.
string w = ostr.str().c_str();
return do_crc(w.begin(), w.end());
-#else
- ostrstream ostr;
- ostr << ifs.rdbuf();
- ostr << '\0';
- char * tmp = ostr.str();
- if (!tmp) return 0; // empty file
- string w(tmp, ostr.tellp());
- unsigned long crc = do_crc(w.begin(), w.end());
- delete tmp;
- return crc;
-#endif
+//#else
+// ostrstream ostr;
+// ostr << ifs.rdbuf();
+// ostr << '\0';
+// char * tmp = ostr.str();
+// if (!tmp) return 0; // empty file
+// string w(tmp, ostr.tellp());
+// unsigned long crc = do_crc(w.begin(), w.end());
+// delete tmp;
+// return crc;
+//#endif
}
--- /dev/null
+/* This is part of libio/iostream, providing -*- C++ -*- input/output.
+Copyright (C) 2000 Free Software Foundation
+
+This file is part of the GNU IO Library. This library is free
+software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As a special exception, if you link this library with files
+compiled with a GNU compiler to produce an executable, this does not cause
+the resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why
+the executable file might be covered by the GNU General Public License. */
+
+/* Written by Magnus Fromreide (magfr@lysator.liu.se). */
+
+/* Sligtly modified for use in The LyX Project.
+ Made to be usable with both std::string (as supplied with Gcc 2.95.2),
+ and with lyxstring. Dynamic casts have been replaced by static_casts.
+ One fix to avoid unsigned/signed warnings.
+
+ Some further changes might be needed to avoid use of namespaces.
+
+ Lars Gullik Bjønnes (larsbj@lyx.org)
+*/
+
+#ifndef SSTREAM_H
+#define SSTREAM_H
+
+#include "LString.h"
+#include <iostream>
+#include <streambuf.h>
+
+namespace std
+{
+ class stringbuf : public streambuf
+ {
+ public:
+ typedef char char_type;
+ typedef int int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+
+ explicit stringbuf(int which=ios::in|ios::out) :
+ streambuf(which), buf(), mode(static_cast<ios::open_mode>(which)),
+ rpos(0), bufsize(1)
+ { }
+
+ explicit stringbuf(const string &s, int which=ios::in|ios::out) :
+ streambuf(which), buf(s), mode(static_cast<ios::open_mode>(which)),
+ bufsize(1)
+ {
+ if(mode & ios::in)
+ {
+ setg(&defbuf, &defbuf + bufsize, &defbuf + bufsize);
+ }
+ if(mode & ios::out)
+ {
+ setp(&defbuf, &defbuf + bufsize);
+ }
+ rpos = (mode & ios::ate ? s.size() : 0);
+ }
+
+ string str() const
+ {
+ const_cast<stringbuf*>(this)->sync(); // Sigh, really ugly hack
+ return buf;
+ };
+
+ void str(const string& s)
+ {
+ buf = s;
+ if(mode & ios::in)
+ {
+ gbump(egptr() - gptr());
+ }
+ if(mode & ios::out)
+ {
+ pbump(pbase() - pptr());
+ }
+ rpos = (mode & ios::ate ? s.size() : 0);
+ }
+
+ protected:
+ inline virtual int sync();
+ inline virtual int overflow(int = EOF);
+ inline virtual int underflow();
+ private:
+ string buf;
+ ios::open_mode mode;
+ string::size_type rpos;
+ streamsize bufsize;
+ char defbuf;
+ };
+
+ class stringstreambase : virtual public ios {
+ protected:
+ stringbuf __my_sb;
+ public:
+ string str() const
+ {
+ return static_cast<stringbuf*>(_strbuf)->str();
+ }
+ void str(const string& s)
+ {
+ clear();
+ static_cast<stringbuf*>(_strbuf)->str(s);
+ }
+
+ stringbuf* rdbuf()
+ {
+ return &__my_sb;
+ }
+ protected:
+ stringstreambase(int which) :
+ __my_sb(which)
+ {
+ init (&__my_sb);
+ }
+
+ stringstreambase(const string& s, int which) :
+ __my_sb(s, which)
+ {
+ init (&__my_sb);
+ }
+ };
+
+ class istringstream : public stringstreambase, public istream {
+ public:
+ istringstream(int which=ios::in) :
+ stringstreambase(which)
+ { }
+
+ istringstream(const string& s, int which=ios::in) :
+ stringstreambase(s, which)
+ { }
+ };
+
+ class ostringstream : public stringstreambase, public ostream {
+ public:
+ ostringstream(int which=ios::out) :
+ stringstreambase(which)
+ { }
+
+ ostringstream(const string& s, int which=ios::out) :
+ stringstreambase(s, which)
+ { }
+ };
+
+ class stringstream : public stringstreambase, public iostream {
+ public:
+ stringstream(int which=ios::in|ios::out) :
+ stringstreambase(which)
+ { }
+
+ stringstream(const string &s, int which=ios::in|ios::out) :
+ stringstreambase(s, which)
+ { }
+ };
+}
+
+inline int stringbuf::sync()
+{
+ if((mode & ios::out) == 0)
+ return EOF;
+
+ streamsize n = pptr() - pbase();
+ if(n)
+ {
+ buf.replace(rpos, string::npos, pbase(), n);
+ //if(buf.size() - rpos != n)
+ if (buf.size() != n + rpos)
+ return EOF;
+ rpos += n;
+ pbump(-n);
+ gbump(egptr() - gptr());
+ }
+ return 0;
+}
+
+inline int stringbuf::overflow(int ch)
+{
+ if((mode & ios::out) == 0)
+ return EOF;
+
+ streamsize n = pptr() - pbase();
+
+ if(n && sync())
+ return EOF;
+
+ if(ch != EOF)
+ {
+ string::size_type oldSize = buf.size();
+
+ buf.replace(rpos, string::npos, 1, ch);
+ if(buf.size() - oldSize != 1)
+ return EOF;
+ ++rpos;
+ }
+ return 0;
+}
+
+inline int stringbuf::underflow()
+{
+ sync();
+ if((mode & ios::in) == 0)
+ {
+ return EOF;
+ }
+ if(rpos >= buf.size())
+ {
+ return EOF;
+ }
+
+ string::size_type n = egptr() - eback();
+ string::size_type s;
+
+ s = buf.copy(eback(), n, rpos);
+ pbump(pbase() - pptr());
+ gbump(eback() - gptr());
+ int res = (0377 & buf[rpos]);
+ rpos += s;
+ return res;
+}
+
+#endif /* not __STRSTREAM__ */
public:
///
enum Starttype {
- System, // Uses system() which uses /bin/sh
- SystemDontWait, // Uses system() which uses /bin/sh
- Wait, // Uses fork() and execvp()
- DontWait // Uses fork() and execvp()
+ /// Uses system() which uses /bin/sh
+ System,
+ /// Uses system() which uses /bin/sh
+ SystemDontWait,
+ /// Uses fork() and execvp()
+ Wait,
+ /// Uses fork() and execvp()
+ DontWait
};
/// Callback function gets commandline and return value from child
Systemcalls();
/** Generate instance and start child process.
- The string "what" contains a commandline with arguments separated
- by spaces.
- When the requested program finishes, the callback-function is
- called with the commandline and the return value from the program.
- The instance is automatically added to a timer check if starttype
- is DontWait (i.e. background execution). When a background child
- finishes, the timer check will automatically call the callback
- function.
- */
+ The string "what" contains a commandline with arguments separated
+ by spaces.
+ When the requested program finishes, the callback-function is
+ called with the commandline and the return value from the program.
+ The instance is automatically added to a timer check if starttype
+ is DontWait (i.e. background execution). When a background child
+ finishes, the timer check will automatically call the callback
+ function.
+ */
Systemcalls(Starttype how, string const & what, Callbackfct call = 0);
///
~Systemcalls();
/** Start childprocess. "what" contains a command at system level.
- * This is for reuse of the Systemcalls instance.
- */
+ This is for reuse of the Systemcalls instance.
+ */
int startscript(Starttype how, string const & what,
Callbackfct call = 0);
- /** gets PID of childprocess. Used by timer */
+ /** gets PID of childprocess.
+ Used by timer
+ */
pid_t getpid() { return pid; }
/// Start callback
void setRetValue(int r) { retval = r; }
/** Kill child prematurely.
- First, a SIGHUP is sent to the child.
- If that does not end the child process within "tolerance"
- seconds, the SIGKILL signal is sent to the child.
- When the child is dead, the callback is called.
+ First, a SIGHUP is sent to the child.
+ If that does not end the child process within "tolerance"
+ seconds, the SIGKILL signal is sent to the child.
+ When the child is dead, the callback is called.
*/
void kill(int tolerance = 5);
private:
class Systemcalls;
+///
class SystemcallsSingletoncontroller {
public:
+ ///
class Startcontroller {
public:
+ ///
Startcontroller();
+ ///
~Startcontroller();
+ ///
static SystemcallsSingletoncontroller * getController();
+ ///
void reduceRefcount() { --refcount; }
private:
+ ///
static SystemcallsSingletoncontroller * contr;
+ ///
static int refcount;
};
+ ///
~SystemcallsSingletoncontroller();
+ ///
void addCall(Systemcalls const & newcall);
+ ///
void timer();
- // private: // DEC cxx does not like that (JMarc)
+ /// private: // DEC cxx does not like that (JMarc)
SystemcallsSingletoncontroller();
private:
+ ///
struct ControlledCalls {
- Systemcalls *call;
- ControlledCalls *next;
+ ///
+ Systemcalls * call;
+ ///
+ ControlledCalls * next;
};
+ ///
ControlledCalls * sysCalls;
};
#include <cctype>
-//
+///
inline
bool IsNewlineChar(char c) {
return (c == LyXParagraph::META_NEWLINE);
}
-//
+///
inline
bool IsSeparatorChar(char c) {
return (c == ' ');
}
-//
+///
inline
bool IsHfillChar(char c) {
return (c == LyXParagraph::META_HFILL);
}
-//
+///
inline
bool IsInsetChar(char c) {
return (c == LyXParagraph::META_INSET);
#ifndef NEW_INSETS
-//
+///
inline
bool IsFloatChar(char c) {
return (c == LyXParagraph::META_FOOTNOTE
#endif
-//
+///
inline
bool IsLineSeparatorChar(char c) {
return (c == ' ');
}
-//
+///
inline
bool IsKommaChar(char c) {
return (c == ','
}
-//
+///
inline
bool IsLetterChar(unsigned char c) {
return ((c >= 'A' && c <= 'Z')
}
-//
+///
inline
bool IsPrintable(unsigned char c) {
return (c >= ' ');
}
-//
+///
inline
bool IsPrintableNonspace(unsigned char c) {
return (c > ' ');
}
-// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset.
+/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset.
inline
bool IsWordChar(unsigned char c) {
return !( IsSeparatorChar( c )
}
-//
+///
inline
bool IsLetterCharOrDigit(char ch)
{
#include "support/LAssert.h"
// Functors used in the template.
+
+///
template<typename T1, typename T2>
class equal_1st_in_pair {
public:
- equal_1st_in_pair(T1 const & value) : value_(value) {}
-
- typedef std::pair<T1, T2> pair_type;
- bool operator() (pair_type const & p) const {
- return p.first == value_;
- }
+ ///
+ equal_1st_in_pair(T1 const & value) : value_(value) {}
+ ///
+ typedef std::pair<T1, T2> pair_type;
+ ///
+ bool operator() (pair_type const & p) const {
+ return p.first == value_;
+ }
private:
- T1 const & value_;
+ ///
+ T1 const & value_;
};
+
+///
template<typename T1, typename T2>
class equal_2nd_in_pair {
public:
- equal_2nd_in_pair(T2 const & value) : value_(value) {}
-
- typedef std::pair<T1, T2> pair_type;
- bool operator() (pair_type const & p) const {
- return p.second == value_;
- }
+ ///
+ equal_2nd_in_pair(T2 const & value) : value_(value) {}
+ ///
+ typedef std::pair<T1, T2> pair_type;
+ ///
+ bool operator() (pair_type const & p) const {
+ return p.second == value_;
+ }
private:
- T2 const & value_;
+ ///
+ T2 const & value_;
};
-/** This class template is used to translate between two elements, specifically
- * it was worked out to translate between an enum and strings when reading
- * the lyx file.
- *
- * The two template arguments should be of different types.
- */
+/** This class template is used to translate between two elements, specifically
+ it was worked out to translate between an enum and strings when reading
+ the lyx file.
+
+ The two template arguments should be of different types.
+*/
template<typename T1, typename T2>
class Translator {
public:
- typedef T1 first_argument_type;
- typedef T2 second_argument_type;
- typedef std::pair<T1, T2> MapPair;
- typedef std::vector<MapPair> Map;
-
- /// c-tor.
- Translator(T1 const & t1, T2 const & t2)
- : default_t1(t1), default_t2(t2)
- {}
-
- /// Add a mapping to the translator.
- void addPair(T1 const & first, T2 const & second) {
- map.push_back(MapPair(first, second));
- }
-
- /// Find the mapping for the first argument
- T2 const & find(T1 const & first) const {
- Assert( ! map.empty());
-
- // For explanation see the next find() function.
- Map::const_iterator it =
- std::find_if(map.begin(), map.end(),
- equal_1st_in_pair<T1, T2>(first)
- );
-
- if (it != map.end())
- return (*it).second;
- else {
- return default_t2;
- }
- }
-
- /// Find the mapping for the second argument
- T1 const & find(T2 const & second) const {
- Assert( ! map.empty());
-
- // The idea is as follows:
- // find_if() will try to compare the data in the vector with the value.
- // The vector is made of pairs and the value has the type of the
- // second part of the pair.
- // We thus give find_if() an equal_to functor and assign to its second
- // post the value we want to compare. We now compose the equal_to
- // functor with the select2nd functor to take only the second value
- // of the pair to be compared.
- //
- // We can depict it as follows:
- // equal_to( select2nd(pair) , second)
- Map::const_iterator it =
- std::find_if(map.begin(), map.end(),
- equal_2nd_in_pair<T1, T2>(second)
- );
-
- if (it != map.end())
- return (*it).first;
- else {
- return default_t1;
- }
- }
-
+ ///
+ typedef T1 first_argument_type;
+ ///
+ typedef T2 second_argument_type;
+ ///
+ typedef std::pair<T1, T2> MapPair;
+ ///
+ typedef std::vector<MapPair> Map;
+
+ ///
+ Translator(T1 const & t1, T2 const & t2)
+ : default_t1(t1), default_t2(t2)
+ {}
+
+ /// Add a mapping to the translator.
+ void addPair(T1 const & first, T2 const & second) {
+ map.push_back(MapPair(first, second));
+ }
+
+ /// Find the mapping for the first argument
+ T2 const & find(T1 const & first) const {
+ Assert(!map.empty());
+
+ // For explanation see the next find() function.
+ Map::const_iterator it =
+ std::find_if(map.begin(), map.end(),
+ equal_1st_in_pair<T1, T2>(first)
+ );
+
+ if (it != map.end()) {
+ return (*it).second;
+ } else {
+ return default_t2;
+ }
+ }
+
+ /// Find the mapping for the second argument
+ T1 const & find(T2 const & second) const {
+ Assert(!map.empty());
+
+ // The idea is as follows:
+ // find_if() will try to compare the data in the vector with
+ // the value. The vector is made of pairs and the value has
+ // the type of the second part of the pair.
+ // We thus give find_if() an equal_to functor and assign to
+ // its second post the value we want to compare. We now
+ // compose the equal_to functor with the select2nd functor
+ // to take only the second value of the pair to be compared.
+ //
+ // We can depict it as follows:
+ // equal_to( select2nd(pair) , second)
+ Map::const_iterator it =
+ std::find_if(map.begin(), map.end(),
+ equal_2nd_in_pair<T1, T2>(second)
+ );
+
+ if (it != map.end())
+ return (*it).first;
+ else {
+ return default_t1;
+ }
+ }
private:
- Map map;
-
- T1 const default_t1;
- T2 const default_t2;
+ ///
+ Map map;
+ ///
+ T1 const default_t1;
+ ///
+ T2 const default_t2;
};
#endif
}
LyXTable::rowstruct &
- LyXTable::rowstruct::operator=(rowstruct const & rs)
+LyXTable::rowstruct::operator=(rowstruct const & rs)
{
top_line = rs.top_line;
bottom_line = rs.bottom_line;
}
LyXTable::columnstruct &
- LyXTable::columnstruct::operator=(columnstruct const & cs)
+LyXTable::columnstruct::operator=(columnstruct const & cs)
{
left_line = cs.left_line;
right_line = cs.right_line;
///
char GetAlignment(int cell); // add approp. signedness
///
- string GetPWidth(int cell);
+ string const GetPWidth(int cell);
///
- string GetAlignSpecial(int cell, int what);
+ string const GetAlignSpecial(int cell, int what);
///
int GetWidthOfCell(int cell);
{
owner_ = inset;
Init(lt.rows_, lt.columns_);
-
+#warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
operator=(lt);
}
LyXTabular * LyXTabular::Clone(InsetTabular * inset)
{
LyXTabular * result = new LyXTabular(inset, *this);
- ///
// don't know if this is good but I need to Clone also
// the text-insets here, this is for the Undo-facility!
- ///
- int i,j;
- for(i=0; i < rows_; ++i) {
- for(j=0; j < columns_; ++j) {
+ for(int i = 0; i < rows_; ++i) {
+ for(int j = 0; j < columns_; ++j) {
result->cell_info[i][j].inset = cell_info[i][j].inset;
result->cell_info[i][j].inset.setOwner(inset);
}
/* activates all lines and sets all widths to 0 */
void LyXTabular::Init(int rows_arg, int columns_arg)
{
- int i, j;
- int cellno = 0;
rows_ = rows_arg;
columns_ = columns_arg;
(rows_, vector<cellstruct>(columns_, cellstruct()));
// Jürgen, use iterators.
- for (i = 0; i < rows_; ++i) {
- for (j = 0; j < columns_; ++j) {
+ int cellno = 0;
+ int i = 0;
+ for (; i < rows_; ++i) {
+ for (int j = 0; j < columns_; ++j) {
cell_info[i][j].inset.setOwner(owner_);
cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
cell_info[i][j].cellno = cellno++;
}
}
- row_info[i-1].bottom_line = true;
+ row_info[i - 1].bottom_line = true;
row_info[0].bottom_line = true;
for (i = 0; i < columns_; ++i) {
calculate_width_of_column(i);
}
- column_info[columns_-1].right_line = true;
+ column_info[columns_ - 1].right_line = true;
calculate_width_of_tabular();
c_info[i][j] = cell_info[i][j];
}
}
- for(int i = row+1; i < rows_; ++i) {
+ for(int i = row + 1; i < rows_; ++i) {
for(int j = 0; j < columns_; ++j) {
c_info[i][j] = cell_info[i-1][j];
}
cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
cellstruct()));
int column = column_of_cell(cell);
- int i, j;
column_vector::iterator cit = column_info.begin() + column + 1;
column_info.insert(cit, columnstruct());
- for (i = 0; i < rows_; ++i) {
- for (j = 0; j <= column; ++j) {
+ for (int i = 0; i < rows_; ++i) {
+ for (int j = 0; j <= column; ++j) {
c_info[i][j] = cell_info[i][j];
}
- for (j = column+1; j < columns_; ++j) {
- c_info[i][j] = cell_info[i][j-1];
+ for (int j = column + 1; j < columns_; ++j) {
+ c_info[i][j] = cell_info[i][j - 1];
}
// care about multicolumns
- if (cell_info[i][column+1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
- cell_info[i][column+1].multicolumn = CELL_PART_OF_MULTICOLUMN;
+ if (cell_info[i][column + 1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
+ cell_info[i][column + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
}
- if (((column+1) == columns_) ||
- (cell_info[i][column+2].multicolumn != CELL_PART_OF_MULTICOLUMN)) {
- cell_info[i][column+1].multicolumn = LyXTabular::CELL_NORMAL;
+ if ((column + 1) == columns_ ||
+ cell_info[i][column + 2].multicolumn != CELL_PART_OF_MULTICOLUMN) {
+ cell_info[i][column + 1].multicolumn = LyXTabular::CELL_NORMAL;
}
}
cell_info = c_info;
++column;
- for (i = 0; i < rows_; ++i) {
+ for (int i = 0; i < rows_; ++i) {
cell_info[i][column].inset.clear();
}
Reinit();
void LyXTabular::Reinit()
{
- int j;
-
- int i = 0;
-
// Jürgen, use iterators.
- for (; i < rows_; ++i) {
- for (j = 0; j < columns_; ++j) {
+ for (int i = 0; i < rows_; ++i) {
+ for (int j = 0; j < columns_; ++j) {
cell_info[i][j].width_of_cell = 0;
cell_info[i][j].inset.setOwner(owner_);
}
}
- for (i = 0; i < columns_; ++i) {
+ for (int i = 0; i < columns_; ++i) {
calculate_width_of_column(i);
}
calculate_width_of_tabular();
int top = 1; // bool top = true; ??
int bottom = 1; // bool bottom = true; ??
- int column;
- for (column = 0; column < columns_ - 1 && bottom; ++column) {
+ for (int column = 0; column < columns_ - 1 && bottom; ++column) {
switch (cell_info[row - 1][column].multicolumn) {
case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
bottom = cell_info[row - 1][column].bottom_line;
bottom = row_info[row - 1].bottom_line;
}
}
- for (column = 0; column < columns_ - 1 && top; ++column) {
+ for (int column = 0; column < columns_ - 1 && top; ++column) {
switch (cell_info[row][column].multicolumn){
case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
top = cell_info[row][column].top_line;
// returns the maximum over all rows
int LyXTabular::GetWidthOfColumn(int cell) const
{
- int column1 = column_of_cell(cell);
- int column2 = right_column_of_cell(cell);
+ int const column1 = column_of_cell(cell);
+ int const column2 = right_column_of_cell(cell);
int result = 0;
int i = column1;
for (; i <= column2; ++i) {
if (!IsMultiColumn(cell))
return false;
- int row = row_of_cell(cell);
- int column1 = column_of_cell(cell);
- int column2 = right_column_of_cell(cell);
+ int const row = row_of_cell(cell);
+ int const column1 = column_of_cell(cell);
+ int const column2 = right_column_of_cell(cell);
// first set columns to 0 so we can calculate the right width
int i = column1;
void LyXTabular::recalculateMulticolCells(int cell, int new_width)
{
- int row = row_of_cell(cell);
- int column1 = column_of_cell(cell);
- int column2 = right_column_of_cell(cell);
+ int const row = row_of_cell(cell);
+ int const column1 = column_of_cell(cell);
+ int const column2 = right_column_of_cell(cell);
// first set columns to 0 so we can calculate the right width
int i = column1;
/* returns 1 if a complete update is necessary, otherwise 0 */
bool LyXTabular::SetWidthOfCell(int cell, int new_width)
{
- int row = row_of_cell(cell);
- int column1 = column_of_cell(cell);
+ int const row = row_of_cell(cell);
+ int const column1 = column_of_cell(cell);
bool tmp = false;
int width = 0;
tmp = calculate_width_of_column_NMC(column1);
}
if (tmp) {
- int i;
- for(i = 0; i<columns_;++i)
+ int i = 0;
+ for(; i<columns_; ++i)
calculate_width_of_column_NMC(i);
- for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
+ for(i = 0; (i < numberofcells) && !IsMultiColumn(i); ++i)
;
- if (i<numberofcells)
+ if (i < numberofcells)
recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
- for(i = 0; i<columns_;++i)
+ for(i = 0; i < columns_; ++i)
calculate_width_of_column(i);
calculate_width_of_tabular();
return true;
bool LyXTabular::SetColumnPWidth(int cell, string const & width)
{
bool flag = !width.empty();
+ int const j = column_of_cell(cell);
- int j = column_of_cell(cell);
- int c;
column_info[j].p_width = width;
if (flag) // do this only if there is a width
SetAlignment(cell, LYX_ALIGN_LEFT);
- for(int i=0; i < rows_; ++i) {
- c = GetCellNumber(i, j);
+ for(int i = 0; i < rows_; ++i) {
+ int c = GetCellNumber(i, j);
flag = !GetPWidth(c).empty(); // because of multicolumns!
GetCellInset(c)->SetAutoBreakRows(flag);
}
bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
{
- bool flag = !width.empty();
+ bool const flag = !width.empty();
cellinfo_of_cell(cell)->p_width = width;
if (IsMultiColumn(cell)) {
bool LyXTabular::SetTopLine(int cell, bool line, bool onlycolumn)
{
- int row = row_of_cell(cell);
+ int const row = row_of_cell(cell);
if (onlycolumn || !IsMultiColumn(cell))
row_info[row].top_line = line;
}
-string LyXTabular::GetPWidth(int cell) const
+string const LyXTabular::GetPWidth(int cell) const
{
if (IsMultiColumn(cell))
return cellinfo_of_cell(cell)->p_width;
}
-string LyXTabular::GetColumnPWidth(int cell) const
+string const LyXTabular::GetColumnPWidth(int cell) const
{
return column_info[column_of_cell(cell)].p_width;
}
-string LyXTabular::GetMColumnPWidth(int cell) const
+string const LyXTabular::GetMColumnPWidth(int cell) const
{
if (IsMultiColumn(cell))
return cellinfo_of_cell(cell)->p_width;
}
-string LyXTabular::GetAlignSpecial(int cell, int what) const
+string const LyXTabular::GetAlignSpecial(int cell, int what) const
{
if (what == SET_SPECIAL_MULTI)
return cellinfo_of_cell(cell)->align_special;
int LyXTabular::GetWidthOfCell(int cell) const
{
- int row = row_of_cell(cell);
- int column1 = column_of_cell(cell);
- int column2 = right_column_of_cell(cell);
+ int const row = row_of_cell(cell);
+ int const column1 = column_of_cell(cell);
+ int const column2 = right_column_of_cell(cell);
int result = 0;
- int i = column1;
- for (; i <= column2; ++i) {
+ for (int i = column1; i <= column2; ++i) {
result += cell_info[row][i].width_of_cell;
}
return result;
bool LyXTabular::calculate_width_of_column(int column)
{
- int old_column_width = column_info[column].width_of_column;
+ int const old_column_width = column_info[column].width_of_column;
int maximum = 0;
for (int i = 0; i < rows_; ++i) {
}
-///
-/// calculate the with of the column without regarding REAL MultiColumn
-/// cells. This means MultiColumn-cells spanning more than 1 column.
-///
+//
+// calculate the with of the column without regarding REAL MultiColumn
+// cells. This means MultiColumn-cells spanning more than 1 column.
+//
bool LyXTabular::calculate_width_of_column_NMC(int column)
{
- int old_column_width = column_info[column].width_of_column;
+ int const old_column_width = column_info[column].width_of_column;
int max = 0;
for (int i = 0; i < rows_; ++i) {
if (!IsMultiColumn(GetCellNumber(i, column), true) &&
int LyXTabular::right_column_of_cell(int cell) const
{
- int row = row_of_cell(cell);
+ int const row = row_of_cell(cell);
int column = column_of_cell(cell);
while (column < (columns_ - 1) &&
cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
void LyXTabular::Write(Buffer const * buf, ostream & os) const
{
- int i, j;
-
// header line
os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
">" << endl;
" endhead=" << endhead << " endfirsthead=" << endfirsthead <<
" endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
">" << endl << endl;
- for (i = 0; i < rows_; ++i) {
+ for (int i = 0; i < rows_; ++i) {
os << "<Row topline=" << row_info[i].top_line <<
" bottomline=" << row_info[i].bottom_line <<
" newpage=" << row_info[i].newpage <<
">" << endl;
- for (j = 0; j < columns_; ++j) {
+ for (int j = 0; j < columns_; ++j) {
if (!i) {
os << "<Column alignment=" << column_info[j].alignment <<
" valignment=" << column_info[j].valignment <<
}
+static inline
void l_getline(istream & is, string & str)
{
getline(is, str);
line << ")" << endl;
return;
}
- (void)getTokenValue(line, "islongtable", is_long_tabular);
- (void)getTokenValue(line, "endhead", endhead);
- (void)getTokenValue(line, "endfirsthead", endfirsthead);
- (void)getTokenValue(line, "endfoot", endfoot);
- (void)getTokenValue(line, "endlastfoot", endlastfoot);
+ getTokenValue(line, "islongtable", is_long_tabular);
+ getTokenValue(line, "endhead", endhead);
+ getTokenValue(line, "endfirsthead", endfirsthead);
+ getTokenValue(line, "endfoot", endfoot);
+ getTokenValue(line, "endlastfoot", endlastfoot);
int i, j;
for(i = 0; i < rows_; ++i) {
l_getline(is, line);
line << ")" << endl;
return;
}
- (void)getTokenValue(line, "topline", row_info[i].top_line);
- (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
- (void)getTokenValue(line, "newpage", row_info[i].newpage);
+ getTokenValue(line, "topline", row_info[i].top_line);
+ getTokenValue(line, "bottomline", row_info[i].bottom_line);
+ getTokenValue(line, "newpage", row_info[i].newpage);
for (j = 0; j < columns_; ++j) {
l_getline(is,line);
if (!prefixIs(line,"<Column")) {
return;
}
if (!i) {
- (void)getTokenValue(line, "alignment", column_info[j].alignment);
- (void)getTokenValue(line, "valignment", column_info[j].valignment);
- (void)getTokenValue(line, "leftline", column_info[j].left_line);
- (void)getTokenValue(line, "rightline", column_info[j].right_line);
- (void)getTokenValue(line, "width", column_info[j].p_width);
- (void)getTokenValue(line, "special", column_info[j].align_special);
+ getTokenValue(line, "alignment", column_info[j].alignment);
+ getTokenValue(line, "valignment", column_info[j].valignment);
+ getTokenValue(line, "leftline", column_info[j].left_line);
+ getTokenValue(line, "rightline", column_info[j].right_line);
+ getTokenValue(line, "width", column_info[j].p_width);
+ getTokenValue(line, "special", column_info[j].align_special);
}
l_getline(is, line);
if (!prefixIs(line, "<Cell")) {
line << ")" << endl;
return;
}
- (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
- (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
- (void)getTokenValue(line, "valignment", cell_info[i][j].valignment);
- (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
- (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
- (void)getTokenValue(line, "leftline", cell_info[i][j].left_line);
- (void)getTokenValue(line, "rightline", cell_info[i][j].right_line);
- (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
- (void)getTokenValue(line, "usebox", cell_info[i][j].usebox);
- (void)getTokenValue(line, "width", cell_info[i][j].p_width);
- (void)getTokenValue(line, "special", cell_info[i][j].align_special);
+ getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
+ getTokenValue(line, "alignment", cell_info[i][j].alignment);
+ getTokenValue(line, "valignment", cell_info[i][j].valignment);
+ getTokenValue(line, "topline", cell_info[i][j].top_line);
+ getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
+ getTokenValue(line, "leftline", cell_info[i][j].left_line);
+ getTokenValue(line, "rightline", cell_info[i][j].right_line);
+ getTokenValue(line, "rotate", cell_info[i][j].rotate);
+ getTokenValue(line, "usebox", cell_info[i][j].usebox);
+ getTokenValue(line, "width", cell_info[i][j].p_width);
+ getTokenValue(line, "special", cell_info[i][j].align_special);
l_getline(is, line);
if (prefixIs(line, "\\begin_inset")) {
cell_info[i][j].inset.Read(buf, lex);
}
-char const * LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
+string const LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
{
int i = isColumn ? cell : column_of_cell(cell);
//i = column_of_cell(cell);
if (!isColumn && IsMultiColumn(cell)) {
if (!cellinfo_of_cell(cell)->align_special.empty()) {
- return cellinfo_of_cell(cell)->align_special.c_str();
+ return cellinfo_of_cell(cell)->align_special;
} else {
switch (GetAlignment(cell)) {
case LYX_ALIGN_LEFT:
}
} else {
if (!column_info[i].align_special.empty()) {
- return column_info[i].align_special.c_str();
+ return column_info[i].align_special;
}
#ifdef IGNORE_THIS_FOR_NOW
else if (!column_info[i].p_width.empty()) {
void LyXTabular::SetLTHead(int cell, bool first)
{
- int row = row_of_cell(cell);
- int val = (row+1) * (column_of_cell(cell)? 1:-1);
+ int const row = row_of_cell(cell);
+ int const val = (row+1) * (column_of_cell(cell)? 1:-1);
if (first) {
if (endfirsthead == val)
void LyXTabular::SetLTFoot(int cell, bool last)
{
- int row = row_of_cell(cell);
- int val = (row + 1) * (column_of_cell(cell)? 1:-1);
+ int const row = row_of_cell(cell);
+ int const val = (row + 1) * (column_of_cell(cell)? 1:-1);
if (last) {
if (endlastfoot == val)
return (row_of_cell(cell) == (abs(endfoot)-1));
}
+
bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const
{
row = endlastfoot;
int LyXTabular::TeXBottomHLine(ostream & os, int row) const
{
- int fcell = GetFirstCellInRow(row);
- int n = NumberOfCellsInRow(fcell) + fcell;
+ int const fcell = GetFirstCellInRow(row);
+ int const n = NumberOfCellsInRow(fcell) + fcell;
int tmp = 0;
- int i;
- for (i = fcell; i < n; ++i) {
+ for (int i = fcell; i < n; ++i) {
if (BottomLine(i))
++tmp;
}
if (tmp == (n-fcell)){
os << "\\hline";
} else {
- for (i = fcell; i < n; ++i) {
+ for (int i = fcell; i < n; ++i) {
if (BottomLine(i)) {
os << "\\cline{"
<< column_of_cell(i) + 1
}
-int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
+int LyXTabular::Latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
{
+#warning Jürgen, this func should be split into more funcs (Lgb)
int ret = 0;
int i,j;
int cell = 0;
return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
}
+
void LyXTabular::Validate(LaTeXFeatures & features) const
{
if (IsLongTabular())
///
char GetVAlignment(int cell, bool onlycolumn = false) const;
///
- string GetPWidth(int cell) const;
+ string const GetPWidth(int cell) const;
///
- string GetColumnPWidth(int cell) const;
+ string const GetColumnPWidth(int cell) const;
///
- string GetMColumnPWidth(int cell) const;
+ string const GetMColumnPWidth(int cell) const;
///
- string GetAlignSpecial(int cell, int what) const;
+ string const GetAlignSpecial(int cell, int what) const;
///
int GetWidthOfCell(int cell) const;
///
int RoffEndOfCell(std::ostream &, int cell);
#endif
///
- char const * GetDocBookAlign(int cell, bool isColumn = false) const;
+ string const GetDocBookAlign(int cell, bool isColumn = false) const;
///
bool IsMultiColumn(int cell, bool real = false) const;
void set_row_column_number_info();
/// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfMulticolCell(int cell, int new_width);
+ ///
void recalculateMulticolCells(int cell, int new_width);
/// Returns true if change
bool calculate_width_of_column(int column);
///
tex_accent accent;
///
- char const *cmd;
+ char const * cmd;
///
- char const *native;
+ char const * native;
///
- char const *name;
+ char const * name;
///
kb_action action;
};
// used all over. As it happens, that meant that these strings were included
// 27 times in the object file. (Asger)
-//
-// extern char const * tex_babel[];
-
///
extern char const * tex_graphics[];
// This function is only used by the spellchecker for NextWord().
// It doesn't handle LYX_ACCENTs and probably never will.
-char * LyXText::SelectNextWord(BufferView * bview, float & value)
+string const LyXText::SelectNextWord(BufferView * bview,
+ float & value) const
{
LyXParagraph * tmppar = cursor.par();
// Start the selection from here
sel_cursor = cursor;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream latex;
-#else
- ostrstream latex;
-#endif
+//#else
+// ostrstream latex;
+//#endif
// and find the end of the word
// (optional hyphens are part of a word)
while (cursor.pos() < cursor.par()->Last()
|| (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos()) != 0
&& cursor.par()->GetInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
&& latex.str() == "\\-"
-#else
- && latex.str() // protect against null pointers
- && string(latex.str(), 3) == "\\-" // this is not nice at all
-#endif
+//#else
+// && latex.str() // protect against null pointers
+// && string(latex.str(), 3) == "\\-" // this is not nice at all
+//#endif
))
cursor.pos(cursor.pos() + 1);
-#ifndef HAVE_SSTREAM
- delete [] latex.str();
-#endif
+//#ifndef HAVE_SSTREAM
+// delete [] latex.str();
+//#endif
// Finally, we copy the word to a string and return it
- char * str = 0;
-
+ string str;
if (sel_cursor.pos() < cursor.pos()) {
- str = new char [cursor.pos() - sel_cursor.pos() + 2];
- LyXParagraph::size_type i, j;
- for (i = sel_cursor.pos(), j = 0; i < cursor.pos(); ++i) {
+ LyXParagraph::size_type i;
+ for (i = sel_cursor.pos(); i < cursor.pos(); ++i) {
if (cursor.par()->GetChar(i) != LyXParagraph::META_INSET)
- str[j++] = cursor.par()->GetChar(i);
+ str += cursor.par()->GetChar(i);
}
- str[j] = '\0';
}
return str;
}
// set the sel cursor
sel_cursor = cursor;
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream latex;
-#else
- ostrstream latex;
-#endif
+//#else
+// ostrstream latex;
+//#endif
// now find the end of the word
while (cursor.pos() < cursor.par()->Last()
|| (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
&& cursor.par()->GetInset(cursor.pos()) != 0
&& cursor.par()->GetInset(cursor.pos())->Latex(bview->buffer(), latex, false, false) == 0
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
&& latex.str() == "\\-"
-#else
- && string(latex.str(), 3) == "\\-"
-#endif
+//#else
+// && string(latex.str(), 3) == "\\-"
+//#endif
)))
cursor.pos(cursor.pos() + 1);
-#ifndef HAVE_SSTREAM
- delete [] latex.str();
-#endif
+//#ifndef HAVE_SSTREAM
+// delete [] latex.str();
+//#endif
SetCursor(bview, cursor.par(), cursor.pos());
// finally set the selection
// smaller. (Asger)
// If position is -1, we get the layout font of the paragraph.
// If position is -2, we get the font of the manual label of the paragraph.
-LyXFont LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
+LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
LyXLayout const & layout =
if (layout.labeltype == LABEL_MANUAL
&& pos < BeginningOfMainBody(buf, par)) {
// 1% goes here
- return par->GetFontSettings(buf->params, pos).
- realize(layout.reslabelfont);
- } else
- return par->GetFontSettings(buf->params, pos).
- realize(layout.resfont);
+ LyXFont f = par->GetFontSettings(buf->params,
+ pos);
+ return f.realize(layout.reslabelfont);
+ } else {
+ LyXFont f = par->GetFontSettings(buf->params, pos);
+ return f.realize(layout.resfont);
+ }
+
} else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
}
-string LyXText::selectionAsString(Buffer const * buffer) const
+string const LyXText::selectionAsString(Buffer const * buffer) const
{
if (!selection) return string();
string result;
void LyXText::SetParagraphExtraOpt(BufferView * bview, int type,
- char const * width,
- char const * widthp,
+ string const & width,
+ string const & widthp,
int alignment, bool hfill,
bool start_minipage)
{
}
-static
-char const * romanCounter(int n)
+static inline
+string const romanCounter(int n)
{
static char const * roman[20] = {
"i", "ii", "iii", "iv", "v",
par->labelstring.erase();
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream s;
-#else
- ostrstream s;
-#endif
+//#else
+// ostrstream s;
+//#endif
if (!par->appendix) {
switch (2 * LABEL_COUNTER_CHAPTER -
textclass.maxcounter() + i) {
break;
}
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
par->labelstring += s.str().c_str();
// We really want to remove the c_str as soon as
// possible...
-#else
- s << '\0';
- char * tmps = s.str();
- par->labelstring += tmps;
- delete [] tmps;
-#endif
+//#else
+// s << '\0';
+// char * tmps = s.str();
+// par->labelstring += tmps;
+// delete [] tmps;
+//#endif
for (i++; i < 10; ++i) {
// reset the following counters
par->incCounter(i + par->enumdepth);
int number = par->getCounter(i + par->enumdepth);
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream s;
-#else
- ostrstream s;
-#endif
+//#else
+// ostrstream s;
+//#endif
switch (par->enumdepth) {
case 1:
if (par->isRightToLeftPar(buf->params))
s << number << '.';
break;
}
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
par->labelstring = s.str().c_str();
// we really want to get rid of that c_str()
-#else
- s << '\0';
- char * tmps = s.str();
- par->labelstring = tmps;
- delete [] tmps;
-#endif
+//#else
+// s << '\0';
+// char * tmps = s.str();
+// par->labelstring = tmps;
+// delete [] tmps;
+//#endif
for (i += par->enumdepth + 1; i < 10; ++i)
par->setCounter(i, 0); /* reset the following counters */
// returns true if the specified string is at the specified position
bool LyXText::IsStringInText(LyXParagraph * par,
LyXParagraph::size_type pos,
- char const * str) const
+ string const & str) const
{
if (par) {
- int i = 0;
- while (pos + i < par->Last() && str[i] &&
+ unsigned int i = 0;
+ while (pos + i < par->Last() && i < str.length()&&
str[i] == par->GetChar(pos + i)) {
++i;
}
- if (!str[i])
+ if (str.length() == i)
return true;
}
return false;
// sets the selection over the number of characters of string, no check!!
-void LyXText::SetSelectionOverString(BufferView * bview, char const * string)
+void LyXText::SetSelectionOverString(BufferView * bview, string const & str)
{
sel_cursor = cursor;
- for (int i = 0; string[i]; ++i)
+ for (int i = 0; str[i]; ++i)
CursorRight(bview);
SetSelection();
}
// simple replacing. The font of the first selected character is used
-void LyXText::ReplaceSelectionWithString(BufferView * bview, char const * str)
+void LyXText::ReplaceSelectionWithString(BufferView * bview,
+ string const & str)
{
SetCursorParUndo(bview->buffer());
FreezeUndo();
// Get font setting before we cut
LyXParagraph::size_type pos = sel_end_cursor.pos();
- LyXFont font = sel_start_cursor.par()->GetFontSettings(bview->buffer()->params,
- sel_start_cursor.pos());
+ LyXFont const font = sel_start_cursor.par()
+ ->GetFontSettings(bview->buffer()->params,
+ sel_start_cursor.pos());
// Insert the new string
- for (int i = 0; str[i]; ++i) {
- sel_end_cursor.par()->InsertChar(pos, str[i], font);
+ for (string::const_iterator cit = str.begin(); cit != str.end(); ++cit) {
+ sel_end_cursor.par()->InsertChar(pos, (*cit), font);
++pos;
}
-
+
// Cut the selection
CutSelection(bview);
// if the string can be found: return true and set the cursor to
// the new position
-bool LyXText::SearchForward(BufferView * bview, char const * str) const
+bool LyXText::SearchForward(BufferView * bview, string const & str) const
{
LyXParagraph * par = cursor.par();
LyXParagraph::size_type pos = cursor.pos();
}
-bool LyXText::SearchBackward(BufferView * bview, char const * string) const
+bool LyXText::SearchBackward(BufferView * bview, string const & str) const
{
LyXParagraph * par = cursor.par();
int pos = cursor.pos();
pos = par->Last() - 1;
} while (par && pos < 0);
}
- } while (par && !IsStringInText(par, pos, string));
+ } while (par && !IsStringInText(par, pos, str));
if (par) {
SetCursor(bview, par, pos);
}
-string DefaultTrans::process(char c, TransManager & k)
+string const DefaultTrans::process(char c, TransManager & k)
{
char dummy[2] = "?";
dummy[0] = c;
Trans::Trans()
{
int i = 0;
- for(; i < 256; ++i)
- keymap_[i] = 0;
-
for(i = 0; i < TEX_MAX_ACCENT + 1; ++i)
kmod_list_[i] = 0;
}
void Trans::FreeKeymap()
{
- int i = 0;
- for(; i < 256; ++i)
- if (keymap_[i]) {
- delete keymap_[i];
- keymap_[i] = 0;
+ for(int i = 0; i < 256; ++i)
+ if (!keymap_[i].empty()) {
+ //delete keymap_[i];
+ keymap_[i].erase();
}
- for(i = 0; i < TEX_MAX_ACCENT + 1; ++i)
+ for(int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
if (kmod_list_[i]) {
FreeException(kmod_list_[i]->exception_list);
delete kmod_list_[i];
}
-bool Trans::IsDefined()
+bool Trans::IsDefined() const
{
return !name_.empty();
}
-string const & Trans::GetName()
+string const & Trans::GetName() const
{
return name_;
}
}
for(string::size_type i = 0; i < keys.length(); ++i) {
- char * temp =
- keymap_[static_cast<unsigned char>(keys[i])] =
- new char[2];
- temp[0] = 0; temp[1] = accent;
+ string * temp =
+ &keymap_[static_cast<unsigned char>(keys[i])];
+ (*temp)[0] = 0; (*temp)[1] = accent;
}
kmod_list_[accent]->exception_list = 0;
}
break;
}
case KCOMB: {
- char const * str;
+ string str;
lyxerr[Debug::KBMAP] << "KCOMB:" << endl;
if (lex.next(true)) {
// check about accent_1 also
int key = 0;
for(; key < 256; ++key) {
- if (keymap_[key] && keymap_[key][0] == 0
+ if (!keymap_[key].empty()
+ && keymap_[key][0] == 0
&& keymap_[key][1] == accent_2)
break;
}
return -1;
if (lex.next(true)) {
- char const * t = lex.text();
- char * string_to =
- strcpy(new char[strlen(t)+1], t);
+ string string_to = lex.text();
+ //char * string_to =
+ // strcpy(new char[strlen(t)+1], t);
keymap_[key_from] = string_to;
if (lyxerr.debugging(Debug::KBMAP))
lyxerr << "\t`" << string_to << "'"
case KXMOD: {
tex_accent accent;
char key;
- char const * str;
+ string str;
if (lyxerr.debugging(Debug::KBMAP))
lyxerr << "KXMOD:\t" << lex.text() << endl;
}
-bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i)
+bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const
{
- if (kmod_list_[accent]!= 0) {
+ if (kmod_list_[accent] != 0) {
i = *kmod_list_[accent];
return true;
}
}
-string Trans::process(char c, TransManager & k)
+string const Trans::process(char c, TransManager & k)
{
- char dummy[2] = "?";
- char * dt = dummy;
- char * t = Match(static_cast<unsigned char>(c));
-
- if ((t == 0 && (*dt = c)) || (t[0] != 0 && (dt = t)) ){
+ string dummy("?");
+ string dt = dummy;
+ string const t = Match(static_cast<unsigned char>(c));
+
+ if (t.empty() && c != 0) {
+ dt[0] = c;
+ return k.normalkey(c, dt);
+ } else if (!t.empty()) {
+ dt = t;
return k.normalkey(c, dt);
} else {
return k.deadkey(c,
class TransInterface {
public:
///
- virtual string process(char, TransManager &) = 0;
+ virtual string const process(char, TransManager &) = 0;
///
- virtual bool isAccentDefined(tex_accent, KmodInfo &) = 0;
+ virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
};
/**
///
DefaultTrans();
///
- virtual string process(char, TransManager &);
+ virtual string const process(char, TransManager &);
private:
///
static bool init_;
///
int Load(string const & language);
///
- bool IsDefined();
+ bool IsDefined() const;
///
- string const & GetName();
+ string const & GetName() const;
///
- string process(char, TransManager &);
+ string const process(char, TransManager &);
///
- bool isAccentDefined(tex_accent, KmodInfo &);
+ bool isAccentDefined(tex_accent, KmodInfo &) const;
private:
///
///
int Load(LyXLex &);
///
- inline char * Match(unsigned char c);
+ inline string const & Match(unsigned char c);
///
void InsertException(keyexc & exclist, char c,
string const & data, bool = false,
///
string name_;
///
- char * keymap_[256];
+ string keymap_[256];
///
kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
///
-char * Trans::Match(unsigned char c)
+string const & Trans::Match(unsigned char c)
{
return keymap_[c];
}
using std::endl;
using std::pair;
-extern string DoAccent(string const &, tex_accent);
-extern string DoAccent(char, tex_accent);
+extern string const DoAccent(string const &, tex_accent);
+extern string const DoAccent(char, tex_accent);
extern BufferView * current_view;
}
-string TransInitState::normalkey(char c, char * t)
+string const TransInitState::normalkey(char c, string const & t)
{
string res;
- if (t) res = t;
+ if (!t.empty()) res = t;
else res = c;
return res;
}
-string TransInitState::deadkey(char c, KmodInfo d)
+string const TransInitState::deadkey(char c, KmodInfo d)
{
deadkey_ = c;
deadkey_info_ = d;
}
-string TransDeadkeyState::normalkey(char c, char * trans)
+string const TransDeadkeyState::normalkey(char c, string const & trans)
{
string res;
}
-string TransDeadkeyState::deadkey(char c, KmodInfo d)
+string const TransDeadkeyState::deadkey(char c, KmodInfo d)
{
string res;
}
-string TransCombinedState::normalkey(char c, char * trans)
+string const TransCombinedState::normalkey(char c, string const & trans)
{
string res;
}
-string TransCombinedState::deadkey(char c, KmodInfo d)
+string const TransCombinedState::deadkey(char c, KmodInfo d)
{
// Third key in a row. Output the first one and
// reenter with shifted deadkeys
}
-bool TransManager::setCharset(char const * set)
+bool TransManager::setCharset(string const & str)
{
- return chset_.loadFile(set);
+ return chset_.loadFile(str);
}
///
virtual ~TransState() {}
///
- virtual string normalkey(char, char *) = 0;
+ virtual string const normalkey(char, string const &) = 0;
///
virtual bool backspace() = 0;
///
- virtual string deadkey(char, KmodInfo) = 0;
+ virtual string const deadkey(char, KmodInfo) = 0;
///
static char const TOKEN_SEP;
};
///
TransInitState();
///
- virtual string normalkey(char, char *);
+ virtual string const normalkey(char, string const &);
///
virtual bool backspace() { return true; }
///
- virtual string deadkey(char, KmodInfo);
+ virtual string const deadkey(char, KmodInfo);
};
///
TransDeadkeyState();
///
- virtual string normalkey(char, char *);
+ virtual string const normalkey(char, string const &);
///
virtual bool backspace() {
currentState = init_state_;
return false;
}
///
- virtual string deadkey(char, KmodInfo);
+ virtual string const deadkey(char, KmodInfo);
};
///
TransCombinedState();
///
- virtual string normalkey(char, char *);
+ virtual string const normalkey(char, string const &);
///
virtual bool backspace() {
// cancel the second deadkey
return false;
}
///
- virtual string deadkey(char, KmodInfo);
+ virtual string const deadkey(char, KmodInfo);
};
///
void DisableKeymap();
///
- bool setCharset(const char *);
+ bool setCharset(string const &);
///
bool backspace() {
return trans_fsm_.currentState->backspace();
///
void TranslateAndInsert(char, LyXText *);
///
- inline string deadkey(char, KmodInfo);
+ inline string const deadkey(char, KmodInfo);
///
- inline string normalkey(char, char *);
+ inline string const normalkey(char, string const &);
///
void deadkey(char, tex_accent, LyXText *);
};
-string TransManager::normalkey(char c, char * t)
+string const TransManager::normalkey(char c, string const & t)
{
return trans_fsm_.currentState->normalkey(c, t);
}
-string TransManager::deadkey(char c, KmodInfo t)
+string const TransManager::deadkey(char c, KmodInfo t)
{
return trans_fsm_.currentState->deadkey(c, t);
}
}
-string RCS::find_file(string const & file)
+string const RCS::find_file(string const & file)
{
string tmp(file);
// Check if *,v exists.
}
-string CVS::find_file(string const & file)
+string const CVS::find_file(string const & file)
{
// First we look for the CVS/Entries in the same dir
// where we have file.
explicit
RCS(string const & m);
///
- static string find_file(string const & file);
+ static string const find_file(string const & file);
///
static void retrive(string const & file);
///
explicit
CVS(string const & m, string const & f);
///
- static string find_file(string const & file);
+ static string const find_file(string const & file);
///
virtual void scanMaster();
///
static inline
-void lyx_advance (string & data, unsigned int n)
+void lyx_advance(string & data, unsigned int n)
{
data.erase(0, n);
}
static inline
-bool isEndOfData (string const & data)
+bool isEndOfData(string const & data)
{
- return frontStrip (data).empty();
+ return frontStrip(data).empty();
}
static
-char nextToken (string & data)
+char nextToken(string & data)
{
data = frontStrip(data);
if (data.empty())
return '\0';
else if (data[0] == '+') {
- lyx_advance (data, 1);
+ lyx_advance(data, 1);
return '+';
- }
- else if (prefixIs(data, "plus")) {
- lyx_advance (data, 4);
+ } else if (prefixIs(data, "plus")) {
+ lyx_advance(data, 4);
return '+';
- }
- else if (data[0] == '-') {
- lyx_advance (data, 1);
+ } else if (data[0] == '-') {
+ lyx_advance(data, 1);
return '-';
- }
- else if (prefixIs(data, "minus")) {
- lyx_advance (data, 5);
+ } else if (prefixIs(data, "minus")) {
+ lyx_advance(data, 5);
return '-';
- }
- else {
+ } else {
string::size_type i;
// I really mean assignment ("=") below, not equality!
if ((i = data.find_last_of("0123456789.")) != string::npos) {
if (number_index > 3) return 'E'; // Error
- string buffer = data.substr(0, i + 1).c_str();
+ string buffer = data.substr(0, i + 1);
double x = strToDbl(buffer);
if (x || (buffer[0] == '0')) {
number[number_index] = x;
- lyx_advance (data, i + 1);
+ lyx_advance(data, i + 1);
++number_index;
return 'n';
} else
!= string::npos) {
if (unit_index > 3) return 'E'; // Error
string buffer = data.substr(0, i + 1);
- unit[unit_index] = unitFromString (buffer);
+ unit[unit_index] = unitFromString(buffer);
if (unit[unit_index] != LyXLength::UNIT_NONE) {
- lyx_advance (data, i + 1);
+ lyx_advance(data, i + 1);
++unit_index;
return 'u';
} else
/// glue, but since we already have it, using it is
/// easier than writing something from scratch.
- string buffer = data;
+ string buffer(data);
int pattern_index = 0;
char pattern[3];
}
-string LyXLength::asString() const
+string const LyXLength::asString() const
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream buffer;
buffer << val << unit_name[uni]; // setw?
return buffer.str().c_str();
-#else
- char tbuf[20];
- ostrstream buffer(tbuf, 20);
- buffer << val << unit_name[uni] << '\0'; // setw?
- return buffer.str();
-#endif
+//#else
+// char tbuf[20];
+// ostrstream buffer(tbuf, 20);
+// buffer << val << unit_name[uni] << '\0'; // setw?
+// return buffer.str();
+//#endif
}
}
-string LyXGlueLength::asString() const
+string const LyXGlueLength::asString() const
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream buffer;
-#else
- char tbuf[20];
- ostrstream buffer(tbuf, 20);
-#endif
+//#else
+// char tbuf[20];
+// ostrstream buffer(tbuf, 20);
+//#endif
if (plus_val != 0.0)
if (minus_val != 0.0)
if ((uni == plus_uni) && (uni == minus_uni))
<< unit_name[minus_uni];
else
buffer << val << unit_name[uni];
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
return buffer.str().c_str();
-#else
- buffer << '\0';
- return buffer.str();
-#endif
+//#else
+// buffer << '\0';
+// return buffer.str();
+//#endif
}
-string LyXGlueLength::asLatexString() const
+string const LyXGlueLength::asLatexString() const
{
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
std::ostringstream buffer;
-#else
- char tbuf[40];
- ostrstream buffer(tbuf, 40);
-#endif
+//#else
+// char tbuf[40];
+// ostrstream buffer(tbuf, 40);
+//#endif
if (plus_val != 0.0)
if (minus_val != 0.0)
<< minus_val << unit_name[minus_uni];
else
buffer << val << unit_name[uni];
-#ifdef HAVE_SSTREAM
+//#ifdef HAVE_SSTREAM
return buffer.str().c_str();
-#else
- buffer << '\0';
- return buffer.str();
-#endif
+//#else
+// buffer << '\0';
+// return buffer.str();
+//#endif
}
}
-string VSpace::asLyXCommand() const
+string const VSpace::asLyXCommand() const
{
string result;
}
-string VSpace::asLatexCommand(BufferParams const & params) const
+string const VSpace::asLatexCommand(BufferParams const & params) const
{
switch (kin) {
case NONE: return string();
LyXLength(string const & data);
///
- float value() const { return val; };
+ float value() const { return val; }
///
- LyXLength::UNIT unit() const { return uni; };
+ LyXLength::UNIT unit() const { return uni; }
/// conversion
- virtual string asString() const;
+ virtual string const asString() const;
///
- virtual string asLatexString() const { return this->asString(); };
-
+ virtual string const asLatexString() const {
+ return this->asString();
+ }
/** If "data" is valid, the length represented by it is
stored into "result", if that is not 0. */
friend bool isValidLength(string const & data,
- LyXLength * result= 0);
+ LyXLength * result = 0);
protected:
///
LyXGlueLength(string const & data);
///
- float plusValue() const { return plus_val; };
+ float plusValue() const { return plus_val; }
///
- LyXLength::UNIT plusUnit() const { return plus_uni; };
+ LyXLength::UNIT plusUnit() const { return plus_uni; }
///
- float minusValue() const { return minus_val; };
+ float minusValue() const { return minus_val; }
///
- LyXLength::UNIT minusUnit() const { return minus_uni; };
+ LyXLength::UNIT minusUnit() const { return minus_uni; }
/// conversion
- virtual string asString() const;
+ virtual string const asString() const;
///
- virtual string asLatexString() const;
+ virtual string const asLatexString() const;
/** If "data" is valid, the length represented by it is
stored into "result", if that is not 0. */
friend bool isValidGlueLength(string const & data,
- LyXGlueLength* result= 0);
+ LyXGlueLength* result = 0);
protected:
///
- float plus_val, minus_val;
+ float plus_val;
+ ///
+ float minus_val;
+ ///
+ LyXLength::UNIT plus_uni;
///
- LyXLength::UNIT plus_uni, minus_uni;
+ LyXLength::UNIT minus_uni;
};
///
///
void setKeep(bool val) { kp = val; }
///
- bool operator == (VSpace const &) const;
+ bool operator==(VSpace const &) const;
// conversion
///
- string asLyXCommand() const; // how it goes into the LyX file
+ string const asLyXCommand() const; // how it goes into the LyX file
///
- string asLatexCommand(BufferParams const & params) const;
+ string const asLatexCommand(BufferParams const & params) const;
///
int inPixels(BufferView * bv) const;
///
int inPixels(int default_height, int default_skip) const;
private:
///
- vspace_kind kin;
+ vspace_kind kin;
///
- LyXGlueLength len;
+ LyXGlueLength len;
///
bool kp;
};