+2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * toc.[Ch]: new files, containing helper functions to handle table
+ of contents
+
+ * lyxfunc.C (dispatch): no need to remove spaces around command
+ given as a string
+ (getStatus): handle LFUN_SEQUENCE by returning the status of the
+ first command of the sequence; it is not very clever, but I do not
+ have a better idea, actually
+
+ * LyXAction.C (LookupFunc): make sure to remove space at the
+ beginning and end of the command
+
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* MenuBackend.C (getMenubar): new method: return the menubar of
// Returns an action tag from a string.
int LyXAction::LookupFunc(string const & func) const
{
- if (func.empty()) return LFUN_NOACTION;
+ string const func2 = frontStrip(strip(func));
+ if (func2.empty()) return LFUN_NOACTION;
// split action and arg
string actstr;
- string const argstr = split(func, actstr, ' ');
+ string const argstr = split(func2, actstr, ' ');
lyxerr[Debug::ACTION] << "Action: " << actstr << '\n';
lyxerr[Debug::ACTION] << "Arg : " << argstr << '\n';
texrow.h \
text.C \
text2.C \
+ toc.C \
+ toc.h \
trans.C \
trans.h \
trans_decl.h \
}
-Buffer::Lists const Buffer::getLists() const
-{
- Lists l;
- Paragraph * par = paragraph;
-
- LyXTextClass const & textclass = textclasslist[params.textclass];
- bool found = textclass.hasLayout("Caption");
- string const layout("Caption");
-
- while (par) {
-#ifdef WITH_WARNINGS
-#warning bogus type (Lgb)
-#endif
- char const labeltype = par->layout()->labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER + params.tocdepth) {
- // insert this into the table of contents
- SingleList & item = l["TOC"];
- int depth = max(0, labeltype - textclass.maxcounter());
- item.push_back(TocItem(par, depth,
- par->asString(this, true)));
- }
- // For each paragraph, traverse its insets and look for
- // FLOAT_CODE
-
- if (found) {
- Paragraph::inset_iterator it =
- par->inset_iterator_begin();
- Paragraph::inset_iterator end =
- par->inset_iterator_end();
-
- for (; it != end; ++it) {
- if ((*it)->lyxCode() == Inset::FLOAT_CODE) {
- InsetFloat * il =
- static_cast<InsetFloat*>(*it);
-
- string const type = il->type();
-
- // Now find the caption in the float...
- // We now tranverse the paragraphs of
- // the inset...
- Paragraph * tmp = il->inset.paragraph();
- while (tmp) {
- if (tmp->layout()->name() == layout) {
- SingleList & item = l[type];
- string const str =
- tostr(item.size()+1) + ". " + tmp->asString(this, false);
- item.push_back(TocItem(tmp, 0 , str));
- }
- tmp = tmp->next();
- }
- }
- }
- } else {
- lyxerr << "Caption not found" << endl;
- }
-
- par = par->next();
- }
- return l;
-}
-
-
// This is also a buffer property (ale)
vector<pair<string, string> > const Buffer::getBibkeyList() const
{
///
std::vector<std::pair<string, string> > const getBibkeyList() const;
///
- struct TocItem {
- TocItem(Paragraph * p, int d, string const & s)
- : par(p), depth(d), str(s) {}
- ///
- Paragraph * par;
- ///
- int depth;
- ///
- string str;
- };
- ///
- typedef std::vector<TocItem> SingleList;
- ///
- typedef std::map<string, SingleList> Lists;
- ///
- Lists const getLists() const;
- ///
std::vector<string> const getLabelList();
/** This will clearly have to change later. Later we can have more
}
-///
-inline
-bool operator==(Buffer::TocItem const & a, Buffer::TocItem const & b)
-{
- return a.par == b.par && a.str == b.str;
- // No need to compare depth.
-}
-
-
-///
-inline
-bool operator!=(Buffer::TocItem const & a, Buffer::TocItem const & b)
-{
- return !(a == b);
- // No need to compare depth.
-}
-
-
///
inline
bool operator==(Buffer::inset_iterator const & iter1,
+2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * ControlToc.C: remove getType
+
2002-07-20 John Levon <moz@compsoc.man.ac.uk>
* ControlCommandBuffer.C: don't add "" to history
#endif
#include "ControlToc.h"
-#include "buffer.h"
+#include "toc.h"
#include "Dialogs.h"
-#include "lyxfunc.h"
-#include "gettext.h"
#include "BufferView.h"
#include "support/lstrings.h" // tostr
using std::vector;
+class Buffer;
ControlToc::ControlToc(LyXView & lv, Dialogs & d)
: ControlCommand(lv, d, LFUN_TOC_INSERT)
{}
-void ControlToc::Goto(int const & id) const
+void ControlToc::goTo(toc::TocItem const & item) const
{
- string const tmp = tostr(id);
- lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp);
+ item.goTo(lv_);
}
vector<string> const ControlToc::getTypes() const
{
- vector<string> types;
-
- Buffer::Lists const tmp = lv_.view()->buffer()->getLists();
-
- Buffer::Lists::const_iterator cit = tmp.begin();
- Buffer::Lists::const_iterator end = tmp.end();
-
- for (; cit != end; ++cit) {
- types.push_back(cit->first);
- }
-
- return types;
+ return toc::getTypes(lv_.view()->buffer());
}
-Buffer::SingleList const ControlToc::getContents(string const & type) const
+toc::Toc const ControlToc::getContents(string const & type) const
{
- Buffer::SingleList empty_list;
+ toc::Toc empty_list;
// This shouldn't be possible...
if (!lv_.view()->available()) {
return empty_list;
}
- Buffer::Lists tmp = lv_.view()->buffer()->getLists();
-
- Buffer::Lists::iterator it = tmp.find(type);
-
+ toc::TocList tmp = toc::getTocList(lv_.view()->buffer());
+ toc::TocList::iterator it = tmp.find(type);
if (it == tmp.end()) {
return empty_list;
}
return it->second;
}
-
-
-namespace toc
-{
-
-string const getType(string const & cmdName)
-{
- string type = cmdName;
-
- // special case
- if (cmdName == "tableofcontents")
- type = "TOC";
-
- return type;
-}
-
-} // namespace toc
#pragma interface
#endif
+#include <vector>
#include "ControlCommand.h"
-#include "buffer.h" // Buffer::SingleList
+#include "toc.h"
/** A controller for TOC dialogs.
*/
ControlToc(LyXView &, Dialogs &);
/// Goto this paragraph id
- void Goto(int const & id) const;
+ void goTo(toc::TocItem const &) const;
- /// Returns a vector of list types in the document
+ /// Return the list of types available
std::vector<string> const getTypes() const;
/// Given a type, returns the contents
- Buffer::SingleList const getContents(string const & type) const;
+ toc::Toc const getContents(string const & type) const;
};
-namespace toc
-{
- /** Given the cmdName of the TOC param, returns the type used
- by ControlToc::getContents() */
- string const getType(string const & cmdName);
-
-} // namespace toc
-
#endif // CONTROLTOC_H
+2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * FormSendto.C:
+ * FormParagraph.C:
+ * FormMinipage.C:
+ * FormGraphics.C:
+ * FormForks.C:
+ * FormCitation.C:
+ * DropDown.C: update to use new getString and getVector
+
+ * xforms_helpers.[Ch]: replace getVectorFromChoice and
+ getVectorFromBrowser by getVector; replace getStringFromInput,
+ getStringFromBrowser and getSelectedStringFromBrowser with
+ getString, which works with input, choice and browser objects
+
+ * Menubar_pimpl.C:
+ * FormToc.C: update to use new toc.[Ch]
+
2002-07-21 John Levon <moz@compsoc.man.ac.uk>
* XFormsView.C: move autosave timer to LyXView.C
{
XUngrabPointer(fl_get_display(), CurrentTime);
fl_hide_form(form_);
- result(getSelectedStringFromBrowser(browser_));
+ result(getString(browser_));
}
// Check whether the current contents of the browser will be
// changed by loading the contents of the vec...
vector<string> const choice_style =
- getVectorFromChoice(dialog->choice_style);
+ getVector(dialog->choice_style);
if (vec == choice_style)
return;
{
// Check whether the current contents of the browser will be
// changed by loading the contents of the vec...
- vector<string> browser_keys = getVectorFromBrowser(browser);
+ vector<string> browser_keys = getVector(browser);
if (browser_keys == keys)
return;
return;
string const current_pid_str =
- getSelectedStringFromBrowser(dialog_->browser_kill);
+ getString(dialog_->browser_kill);
pid_t const current_pid = strToInt(current_pid_str);
vector<pid_t> pids = controller().getPIDs();
for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_kill);
++i) {
string const pid_str =
- getStringFromBrowser(dialog_->browser_kill, i);
+ getString(dialog_->browser_kill, i);
pid_t const pid = strToInt(pid_str);
vector<pid_t>::const_iterator it =
find(pids.begin(), pids.end(), pid);
{
// Get the list of all processes to kill.
vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ getVector(dialog_->browser_kill);
if (kill_vec.empty())
return;
for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_children);
++i) {
string const selection =
- getStringFromBrowser(dialog_->browser_children, i);
+ getString(dialog_->browser_children, i);
string pid_str;
split(selection, pid_str, '\t');
// be added to this list if so desired.
string const selection =
- getSelectedStringFromBrowser(dialog_->browser_children);
+ getString(dialog_->browser_children);
string pid_str;
split(selection, pid_str, '\t');
vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ getVector(dialog_->browser_kill);
vector<string>::const_iterator it =
find(kill_vec.begin(), kill_vec.end(), pid_str);
// 3. Disable the add button.
string const pid_str =
- getSelectedStringFromBrowser(dialog_->browser_kill);
+ getString(dialog_->browser_kill);
// Find this string in the list of all child processes
vector<string> const child_vec =
- getVectorFromBrowser(dialog_->browser_children);
+ getVector(dialog_->browser_children);
vector<string>::const_iterator it =
find_if(child_vec.begin(), child_vec.end(), FindPID(pid_str));
vector<string> const getPIDvector(FL_OBJECT * ob)
{
- vector<string> vec = getVectorFromBrowser(ob);
+ vector<string> vec = getVector(ob);
if (vec.empty())
return vec;
// 3. Deactivate the "add" button.
- string const selection =
- getSelectedStringFromBrowser(dialog_->browser_children);
+ string const selection = getString(dialog_->browser_children);
string pid_str;
split(selection, pid_str, '\t');
vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ getVector(dialog_->browser_kill);
vector<string>::const_iterator it =
find(kill_vec.begin(), kill_vec.end(), pid_str);
InsetGraphicsParams & igp = controller().params();
// the file section
- igp.filename = getStringFromInput(file_->input_filename);
+ igp.filename = getString(file_->input_filename);
igp.subcaption = fl_get_button(file_->check_subcaption);
- igp.subcaptionText = getStringFromInput(file_->input_subcaption);
+ igp.subcaptionText = getString(file_->input_subcaption);
igp.rotate = fl_get_button(file_->check_rotate);
igp.rotateAngle =
- strToDbl(getStringFromInput(file_->input_rotate_angle));
+ strToDbl(getString(file_->input_rotate_angle));
while (igp.rotateAngle < 0.0 || igp.rotateAngle > 360.0) {
if (igp.rotateAngle < 0.0) {
igp.rotateAngle += 360.0;
igp.lyxheight = getLyXLengthFromWidgets(lyxview_->input_lyxheight,
lyxview_->choice_lyxheight);
- igp.lyxscale = strToInt(getStringFromInput(lyxview_->input_lyxscale));
+ igp.lyxscale = strToInt(getString(lyxview_->input_lyxscale));
igp.keepLyXAspectRatio = fl_get_button(lyxview_->check_lyxaspectratio);
// the size section
igp.height = getLyXLengthFromWidgets(size_->input_height,
size_->choice_height);
- igp.scale = strToInt(getStringFromInput(size_->input_scale));
+ igp.scale = strToInt(getString(size_->input_scale));
igp.keepAspectRatio = fl_get_button(size_->check_aspectratio);
// the bb section
igp.bb = string(); // don't write anything
else {
string bb;
- if (getStringFromInput(bbox_->input_bb_x0).empty())
+ if (getString(bbox_->input_bb_x0).empty())
bb = "0 ";
else
bb = getLengthFromWidgets(bbox_->input_bb_x0,
bbox_->choice_bb_units)+" ";
- if (getStringFromInput(bbox_->input_bb_y0).empty())
+ if (getString(bbox_->input_bb_y0).empty())
bb += "0 ";
else
bb += (getLengthFromWidgets(bbox_->input_bb_y0,
bbox_->choice_bb_units)+" ");
- if (getStringFromInput(bbox_->input_bb_x1).empty())
+ if (getString(bbox_->input_bb_x1).empty())
bb += "0 ";
else
bb += (getLengthFromWidgets(bbox_->input_bb_x1,
bbox_->choice_bb_units)+" ");
- if (getStringFromInput(bbox_->input_bb_y1).empty())
+ if (getString(bbox_->input_bb_y1).empty())
bb += "0 ";
else
bb += (getLengthFromWidgets(bbox_->input_bb_y1,
igp.clip = fl_get_button(bbox_->check_clip);
// the special section
- igp.special = getStringFromInput(special_->input_special);
+ igp.special = getString(special_->input_special);
}
bool isValid(FL_OBJECT * ob)
{
- string const input = getStringFromInput(ob);
+ string const input = getString(ob);
return input.empty() || isValidLength(input) || isStrDbl(input);
}
// the file section
if (ob == file_->button_browse) {
// Get the filename from the dialog
- string const in_name = getStringFromInput(file_->input_filename);
+ string const in_name = getString(file_->input_filename);
string const out_name = controller().Browse(in_name);
lyxerr[Debug::GRAPHICS] << "[FormGraphics]out_name: " << out_name << endl;
if (out_name != in_name && !out_name.empty()) {
updateWidgetsFromLength(lyxview_->input_lyxheight,
lyxview_->choice_lyxheight,
dummy, defaultUnit);
- string const scale = getStringFromInput(size_->input_scale);
+ string const scale = getString(size_->input_scale);
fl_set_input(lyxview_->input_lyxscale, scale.c_str());
if (fl_get_button (size_->radio_asis) == 1) {
fl_set_button (lyxview_->radio_lyxasis, 1);
ob == bbox_->input_bb_x1 || ob == bbox_->input_bb_y1)) {
controller().bbChanged = true;
} else if (ob == bbox_->button_getBB) {
- string const filename = getStringFromInput(file_->input_filename);
+ string const filename = getString(file_->input_filename);
if (!filename.empty()) {
string bb = controller().readBB(filename);
if (!bb.empty()) {
updateWidgetsFromLength(size_->input_height,
size_->choice_height,
dummy, defaultUnit);
- string const scale = getStringFromInput(lyxview_->input_lyxscale);
+ string const scale = getString(lyxview_->input_lyxscale);
fl_set_input(size_->input_scale, scale.c_str());
if (fl_get_button (lyxview_->radio_lyxasis) == 1) {
fl_set_button (size_->radio_asis, 1);
// disallow senseless data
// warnings if input is senseless
if (ob == dialog_->input_width) {
- string const input = getStringFromInput(dialog_->input_width);
+ string const input = getString(dialog_->input_width);
bool const invalid = !isValidLength(input) && !isStrDbl(input);
if (invalid) {
postWarning(_("Invalid Length!"));
// If a vspace kind is "Length" but there's no text in
// the input field, reset the kind to "None".
- string const input = strip(getStringFromInput(input_length));
+ string const input = strip(getString(input_length));
if (input.empty())
fl_set_choice(choice_type, 1);
}
/* label width */
string const labelwidthstring =
- getStringFromInput(dialog_->input_labelwidth);
+ getString(dialog_->input_labelwidth);
controller().params().labelWidthString(labelwidthstring);
/* indendation */
break;
case 5:
linespacing = Spacing::Other;
- other = getStringFromInput(dialog_->input_linespacing);
+ other = getString(dialog_->input_linespacing);
break;
}
setEnabled(input_length, true);
setEnabled(choice_length, true);
- string const length = getStringFromInput(input_length);
+ string const length = getString(input_length);
if (strip(length).empty()) {
bool const metric = lyxrc.default_papersize > 3;
if (fl_get_choice(choice_type) != 7)
return true;
- string const input = getStringFromInput(input_length);
+ string const input = getString(input_length);
return (input.empty() ||
isValidGlueLength(input) ||
isStrDbl(input));
}
double const spacing =
- strToDbl(getStringFromInput(dialog_->input_linespacing));
+ strToDbl(getString(dialog_->input_linespacing));
if (choice_spacing == 5 && int(spacing) == 0)
valid = false;
// Get the available buffers
vector<string> const buffers = controller().getBufferList();
vector<string> const choice_buffers =
- getVectorFromChoice(dialog_->choice_buffer);
+ getVector(dialog_->choice_buffer);
// If different from the current contents of the choice, then update it
if (buffers != choice_buffers) {
if (fl_get_button(dialog_->check_sort))
sort(keys.begin(), keys.end());
- vector<string> browser_keys =
- getVectorFromBrowser(dialog_->browser_refs);
+ vector<string> browser_keys = getVector(dialog_->browser_refs);
if (browser_keys == keys)
return;
}
vector<string> const browser_keys =
- getVectorFromBrowser(dialog_->browser_formats);
+ getVector(dialog_->browser_formats);
if (browser_keys == keys)
return;
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
return ButtonPolicy::SMI_INVALID;
- string cmd = getStringFromInput(dialog_->input_command);
+ string cmd = getString(dialog_->input_command);
cmd = strip(frontStrip(cmd));
if (cmd.empty())
return ButtonPolicy::SMI_INVALID;
if (line < 1 || line > fl_get_browser_maxline(dialog_->browser_formats))
return;
- string const cmd = getStringFromInput(dialog_->input_command);
+ string const cmd = getString(dialog_->input_command);
controller().setFormat(all_formats_[line-1]);
controller().setCommand(cmd);
ButtonPolicy::SMInput FormSpellchecker::input(FL_OBJECT * obj, long val)
{
if (obj == dialog_->button_replace) {
- string const tmp = getStringFromInput(dialog_->input);
+ string const tmp = getString(dialog_->input);
controller().replace(tmp);
} else if (obj == dialog_->button_start) {
} else if (obj == dialog_->browser) {
int const line = fl_get_browser(dialog_->browser);
string const tmp =
- getStringFromBrowser(dialog_->browser, line);
+ getString(dialog_->browser, line);
if (tmp.empty())
return ButtonPolicy::SMI_NOOP;
#include "FormToc.h"
#include "xformsBC.h"
+#include "xforms_helpers.h"
#include "ControlToc.h"
#include "forms/form_toc.h"
-#include "helper_funcs.h" // getStringFromVector
#include "support/lstrings.h" // frontStrip, strip
#include "debug.h"
#include "gettext.h"
{
dialog_.reset(build_toc(this));
+ vector<string> types = controller().getTypes();
+
+
string const choice =
" " + getStringFromVector(controller().getTypes(), " | ") + " ";
fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
if (ob == dialog_->browser_toc) {
unsigned int const choice = fl_get_browser(dialog_->browser_toc);
- if (choice - 1 < toclist_.size() && choice >= 1) {
- controller().Goto(toclist_[choice - 1].par->id());
+ if (choice - 1 < toc_.size() && choice >= 1) {
+ controller().goTo(toc_[choice - 1]);
}
return ButtonPolicy::SMI_VALID;
}
// And select the correct one
string const type = toc::getType(controller().params().getCmdName());
-
- fl_set_choice(dialog_->choice_toc_type, 1);
- for (int i = 1;
- i <= fl_get_choice_maxitems(dialog_->choice_toc_type); ++i) {
- string const choice =
- fl_get_choice_item_text(dialog_->choice_toc_type, i);
-
- if (choice == type) {
- fl_set_choice(dialog_->choice_toc_type, i);
- break;
- }
- }
+ fl_set_choice_text(dialog_->choice_toc_type, type.c_str());
}
void FormToc::updateContents()
{
- char const * tmp = fl_get_choice_text(dialog_->choice_toc_type);
-
- if (!tmp) {
+ string const type = getString(dialog_->choice_toc_type);
+ if (type.empty()) {
fl_clear_browser(dialog_->browser_toc);
fl_add_browser_line(dialog_->browser_toc,
_("*** No Lists ***"));
+ setEnabled(dialog_->browser_toc, false);
return;
}
- string const type = frontStrip(strip(tmp));
+ toc::Toc const contents = controller().getContents(type);
- Buffer::SingleList const contents = controller().getContents(type);
+ // Check if all elements are the same.
+ if (toc_ == contents) {
+ return;
+ }
+
+ // List has changed. Update browser
+ toc_ = contents;
if (contents.empty()) {
fl_clear_browser(dialog_->browser_toc);
fl_add_browser_line(dialog_->browser_toc,
_("*** No Lists ***"));
- }
-
- // Check if all elements are the same.
- if (toclist_ == contents) {
+ setEnabled(dialog_->browser_toc, false);
return;
}
- // List has changed. Update browser
- toclist_ = contents;
-
unsigned int const topline =
fl_get_browser_topline(dialog_->browser_toc);
unsigned int const line = fl_get_browser(dialog_->browser_toc);
fl_clear_browser(dialog_->browser_toc);
+ setEnabled(dialog_->browser_toc, true);
- Buffer::SingleList::const_iterator cit = toclist_.begin();
- Buffer::SingleList::const_iterator end = toclist_.end();
-
+ toc::Toc::const_iterator cit = contents.begin();
+ toc::Toc::const_iterator end = contents.end();
for (; cit != end; ++cit) {
- string const line = string(4 * cit->depth, ' ') + cit->str;
- fl_add_browser_line(dialog_->browser_toc, line.c_str());
+ fl_add_browser_line(dialog_->browser_toc,
+ cit->asString().c_str());
}
fl_set_browser_topline(dialog_->browser_toc, topline);
#endif
#include "FormBase.h"
-#include "buffer.h"
+#include "toc.h"
class ControlToc;
struct FD_toc;
void updateContents();
///
- Buffer::SingleList toclist_;
+ toc::Toc toc_;
};
#endif // FORMTOC_H
#include "MenuBackend.h"
#include "LyXAction.h"
#include "kbmap.h"
-#include "buffer.h"
#include "Dialogs.h"
#include "XFormsView.h"
#include "lyxfunc.h"
#include "support/LAssert.h"
#include "gettext.h"
#include "debug.h"
+#include "toc.h"
#include FORMS_H_LOCATION
#include <boost/scoped_ptr.hpp>
void add_toc2(int menu, string const & extra_label,
vector<int> & smn, Window win,
- vector<Buffer::TocItem> const & toc_list,
+ toc::Toc const & toc_list,
size_type from, size_type to, int depth)
{
int shortcut_count = 0;
if (to - from <= max_number_of_items) {
for (size_type i = from; i < to; ++i) {
- int const action = lyxaction.
- getPseudoAction(LFUN_GOTO_PARAGRAPH,
- tostr(toc_list[i].par->id()));
+ int const action = toc_list[i].action();
string label(4 * max(0, toc_list[i].depth - depth),' ');
label += fixlabel(toc_list[i].str);
label = limit_string_length(label);
toc_list[new_pos].depth > depth)
++new_pos;
- int const action = lyxaction.
- getPseudoAction(LFUN_GOTO_PARAGRAPH,
- tostr(toc_list[pos].par->id()));
+ int const action = toc_list[pos].action();
string label(4 * max(0, toc_list[pos].depth - depth), ' ');
label += fixlabel(toc_list[pos].str);
label = limit_string_length(label);
{
if (!owner_->buffer())
return;
- Buffer::Lists toc_list = owner_->buffer()->getLists();
- Buffer::Lists::const_iterator cit = toc_list.begin();
- Buffer::Lists::const_iterator end = toc_list.end();
+ toc::TocList toc_list = toc::getTocList(owner_->buffer());
+ toc::TocList::const_iterator cit = toc_list.begin();
+ toc::TocList::const_iterator end = toc_list.end();
for (; cit != end; ++cit) {
// Handle this elsewhere
if (cit->first == "TOC") continue;
// All the rest is for floats
int menu_first_sub = get_new_submenu(smn, win);
int menu_current = menu_first_sub;
- Buffer::SingleList::const_iterator ccit = cit->second.begin();
- Buffer::SingleList::const_iterator eend = cit->second.end();
+ toc::Toc::const_iterator ccit = cit->second.begin();
+ toc::Toc::const_iterator eend = cit->second.end();
size_type count = 0;
for (; ccit != eend; ++ccit) {
++count;
count = 1;
menu_current = menu_tmp;
}
- int const action =
- lyxaction
- .getPseudoAction(LFUN_GOTO_PARAGRAPH,
- tostr(ccit->par->id()));
+ int const action = ccit->action();
string label = fixlabel(ccit->str);
label = limit_string_length(label);
label += "%x" + tostr(action + action_offset);
}
-// Given an fl_choice, create a vector of its entries
-vector<string> const getVectorFromChoice(FL_OBJECT * ob)
+// Given an fl_choice or an fl_browser, create a vector of its entries
+vector<string> const getVector(FL_OBJECT * ob)
{
- vector<string> vec;
- if (!ob || ob->objclass != FL_CHOICE)
- return vec;
-
- for(int i = 0; i < fl_get_choice_maxitems(ob); ++i) {
- string const text = fl_get_choice_item_text(ob, i+1);
- vec.push_back(strip(frontStrip(text)));
+ vector <string> vec;
+
+ switch (ob->objclass) {
+ case FL_CHOICE:
+ for(int i = 0; i < fl_get_choice_maxitems(ob); ++i) {
+ string const text = fl_get_choice_item_text(ob, i+1);
+ vec.push_back(strip(frontStrip(text)));
+ }
+ break;
+ case FL_BROWSER:
+ for(int i = 0; i < fl_get_browser_maxline(ob); ++i) {
+ string const text = fl_get_browser_line(ob, i+1);
+ vec.push_back(strip(frontStrip(text)));
+ }
+ break;
+ default:
+ lyx::Assert(0);
}
-
+
return vec;
}
-/// Given an fl_input, return its contents.
-string const getStringFromInput(FL_OBJECT * ob)
-{
- if (!ob || ob->objclass != FL_INPUT)
- return string();
-
- char const * tmp = fl_get_input(ob);
- return (tmp) ? tmp : string();
-}
-
-
-// Given an fl_browser, return the contents of line
-string const getStringFromBrowser(FL_OBJECT * ob, int line)
+///
+string const getString(FL_OBJECT * ob, int line)
{
- if (!ob || ob->objclass != FL_BROWSER ||
- line < 1 || line > fl_get_browser_maxline(ob))
- return string();
-
- char const * tmp = fl_get_browser_line(ob, line);
- return (tmp) ? tmp : string();
+ char const * tmp = 0;
+
+ switch (ob->objclass) {
+ case FL_INPUT:
+ lyx::Assert(line == -1);
+ tmp = fl_get_input(ob);
+ break;
+ case FL_BROWSER:
+ if (line == -1)
+ line = fl_get_browser(ob);
+
+ if (line >= 1 && line <= fl_get_browser_maxline(ob))
+ tmp = fl_get_browser_line(ob, line);
+ break;
+
+ case FL_CHOICE:
+ if (line == -1)
+ line = fl_get_choice(ob);
+
+ if (line >= 1 && line <= fl_get_choice_maxitems(ob))
+ tmp = fl_get_choice_item_text(ob, line);
+ break;
+
+ default:
+ lyx::Assert(0);
+ }
+
+ return (tmp) ? frontStrip(strip(tmp)) : string();
}
-
-// Given an fl_browser, return the contents of the currently
-// highlighted line.
-// If nothing is selected, return an empty string
-string const getSelectedStringFromBrowser(FL_OBJECT * ob)
-{
- if (!ob || ob->objclass != FL_BROWSER)
- return string();
-
- int const line = fl_get_browser(ob);
- if (line < 1 || line > fl_get_browser_maxline(ob))
- return string();
-
- if (!fl_isselected_browser_line(ob, line))
- return string();
-
- char const * tmp = fl_get_browser_line(ob, line);
- return (tmp) ? tmp : string();
-}
-
-
-// Given an fl_browser, create a vector of its entries
-vector<string> const getVectorFromBrowser(FL_OBJECT * ob)
-{
- vector<string> vec;
- if (!ob || ob->objclass != FL_BROWSER)
- return vec;
-
- for(int i = 0; i < fl_get_browser_maxline(ob); ++i) {
- string const text = fl_get_browser_line(ob, i+1);
- vec.push_back(strip(frontStrip(text)));
- }
-
- return vec;
-}
-
-
+
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice)
{
// Paranoia check
// Else set the choice to the default unit.
string const unit = subst(stringFromUnit(len.unit()),"%","%%");
- vector<string> const vec = getVectorFromChoice(choice);
+ vector<string> const vec = getVector(choice);
vector<string>::const_iterator it =
std::find(vec.begin(), vec.end(), unit);
if (it != vec.end()) {
string formatted(string const &label, int w,
int = 12 /*FL_NORMAL_SIZE*/, int = 0 /*FL_NORMAL_STYLE*/);
-/// Given an fl_choice, create a vector of its entries
-std::vector<string> const getVectorFromChoice(FL_OBJECT *);
-
-/// Given an fl_browser, create a vector of its entries
-std::vector<string> const getVectorFromBrowser(FL_OBJECT *);
-
-/// Given an fl_input, return its contents.
-string const getStringFromInput(FL_OBJECT * ob);
-
-/** Given an fl_browser, return the contents of line
- (xforms numbering convention; starts at 1).
-*/
-string const getStringFromBrowser(FL_OBJECT * ob, int line);
-/** Given an fl_browser, return the contents of the currently
- highlighted line.
-*/
-string const getSelectedStringFromBrowser(FL_OBJECT * ob);
+/// Given an fl_choice or an fl_browser, create a vector of its entries
+std::vector<string> const getVector(FL_OBJECT *);
+
+/// Given an fl_input, an fl_choice or an fl_browser, return an entry
+/** \c num is the position for the string, where -1 means "current item" */
+string const getString(FL_OBJECT * ob, int num = -1);
/// Given input and choice widgets, create a string such as "1cm"
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);
+2002-07-21 Herbert Voss <voss@lyx.org>
+
+ * GraphicsImage.C: get the LyXAspectRatio run.
+
+ * GraphicsParams.[Ch]: add bool keepLyXXAspectRatio
+
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* PreviewLoader.C (startLoading): pass an interger as resolution
*
* \author Baruch Even <baruch.even@writeme.com>
* \author Angus Leeming <leeming@lyx.org>
+ * \author Herbert Voss <voss@lyx.org>
*/
#include <config.h>
#include "GraphicsImage.h"
#include "GraphicsParams.h"
+#include "debug.h"
+
+using std::endl;
+using std::abs;
namespace grfx {
std::pair<unsigned int, unsigned int>
Image::getScaledDimensions(Params const & params) const
{
- if (params.scale == 0 && params.width == 0 && params.height == 0)
- // No scaling
+ lyxerr[Debug::GRAPHICS]
+ << "GraphicsImage::getScaledDImensions()"
+ << "\n\tparams.scale : " << params.scale
+ << "\n\tparams.width : " << params.width
+ << "\n\tparams.height : " << params.height
+ << "\n\tkeepLyXAspectRatio : " << params.keepLyXAspectRatio
+ << std::endl;
+ if (params.width == 0 && params.height == 0 && params.scale == 0) {
+ // original size or scale/custom without any input
+ lyxerr[Debug::GRAPHICS]
+ << "\treturn with the original values!\n";
return std::make_pair(getWidth(), getHeight());
-
+ }
+
typedef unsigned int dimension;
dimension width = 0;
dimension height = 0;
if (params.scale != 0) {
- width = dimension(getWidth() * params.scale / 100.0);
+ // GraphicsParams::Scale
+ width = dimension(double(getWidth()) * params.scale / 100.0);
height = dimension(getHeight() * params.scale / 100.0);
- } else {
- width = params.width;
- height = params.height;
+ return std::make_pair(width, height);
+ }
+ // GraphicsParams::WH
+ width = (params.width > 0) ? params.width : getWidth();
+ height = (params.height > 0) ? params.height : getHeight();
+ if (!params.keepLyXAspectRatio)
+ return std::make_pair(width, height);
- if (width == 0) {
- width = height * getWidth() / getHeight();
- } else if (height == 0) {
- height = width * getHeight() / getWidth();
- }
+ // calculate aspect ratio
+ float const rw = getWidth();
+ float const rh = getHeight();
+ // there must be a width for the division
+ float const ratio = (rw > 0.001) ? rh/rw : 1.0;
+ lyxerr[Debug::GRAPHICS]
+ << "\tValue of LyXAspectRatio: " << ratio << std::endl;
+ // there are now four different cases
+ // w=0 & h=0 -> see above, no more possible at this place
+ // w>0 & h=0 -> calculate h
+ // w=0 & h>0 -> calculate w
+ // w>0 & h>0 -> the greatest difference to the original
+ // value becomes the same
+ if (params.width > 0 && params.height > 0) {
+ // both widths are given and keepAspectRatio, too
+ int const diff_width = abs(int(getWidth() - params.width));
+ int const diff_height= abs(int(getHeight() - params.height));
+ if (diff_width > diff_height)
+ height = int(ratio * params.width);
+ else
+ width = int(ratio * params.height);
+ return std::make_pair(width, height);
}
-
- if (width == 0 || height == 0)
- // Something is wrong!
- return std::make_pair(getWidth(), getHeight());
-
- return std::make_pair(width, height);
+ if (params.width > 0) {
+ width = params.width;
+ height = int(ratio * params.width);
+ return std::make_pair(width, height);
+ }
+ if (params.height > 0) {
+ height = params.height;
+ width = int(ratio * params.height);
+ return std::make_pair(width, height);
+ }
+ // all other cases ... kind of paranoia :-)
+ return std::make_pair(getWidth(), getHeight());
}
} // namespace grfx
+
width(0),
height(0),
scale(0),
+ keepLyXAspectRatio(false),
angle(0)
{}
bool operator==(Params const & a, Params const & b)
{
- return (a.filename == b.filename &&
- a.display == b.display &&
- a.bb == b.bb &&
- a.width == b.width &&
- a.height == b.height &&
- a.scale == b.scale &&
- a.angle == b.angle);
+ return (a.filename == b.filename &&
+ a.display == b.display &&
+ a.bb == b.bb &&
+ a.width == b.width &&
+ a.height == b.height &&
+ a.scale == b.scale &&
+ a.keepLyXAspectRatio == b.keepLyXAspectRatio &&
+ a.angle == b.angle);
}
unsigned int width;
unsigned int height;
unsigned int scale;
+ bool keepLyXAspectRatio;
/// Rotation angle.
int angle;
+2002-07-21 Herbert Voss <voss@lyx.org>
+
+ * insetgraphicsParams.C: fet the keepLyXAspectRatio run. Move the
+ image relevant part into graphics/GraphicsImgae.C
+
+2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * insettoc.C (ascii):
+ * insetfloatlist.C (ascii): change to use the new Toc functions
+ instead of stuff that was in Buffer
+
2002-07-20 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insettext.C (localDispatch): BufferView::Dispatch has been
#include "insetfloatlist.h"
#include "FloatList.h"
#include "LaTeXFeatures.h"
+#include "lyxlex.h"
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
#include "BufferView.h"
-#include "buffer.h"
+#include "toc.h"
#include "gettext.h"
#include "debug.h"
{
os << getScreenLabel(buffer) << "\n\n";
- Buffer::Lists const toc_list = buffer->getLists();
- Buffer::Lists::const_iterator cit =
- toc_list.find(getCmdName());
- if (cit != toc_list.end()) {
- Buffer::SingleList::const_iterator ccit = cit->second.begin();
- Buffer::SingleList::const_iterator end = cit->second.end();
- for (; ccit != end; ++ccit)
- os << string(4 * ccit->depth, ' ')
- << ccit->str << "\n";
- }
+ toc::asciiTocList(getCmdName(), buffer, os);
os << "\n";
return 0;
pars.width = 0;
pars.height = 0;
pars.scale = 0;
+ pars.keepLyXAspectRatio = false;
pars.angle = 0;
pars.filename = filename;
if (rotate)
pars.angle = int(rotateAngle);
- if (display == InsetGraphicsParams::DEFAULT) {
-
- if (lyxrc.display_graphics == "mono")
- pars.display = grfx::MonochromeDisplay;
- else if (lyxrc.display_graphics == "gray")
- pars.display = grfx::GrayscaleDisplay;
- else if (lyxrc.display_graphics == "color")
- pars.display = grfx::ColorDisplay;
- else
+ switch (display) {
+ case InsetGraphicsParams::NONE:
pars.display = grfx::NoDisplay;
+ break;
- } else if (display == InsetGraphicsParams::NONE) {
- pars.display = grfx::NoDisplay;
-
- } else if (display == InsetGraphicsParams::MONOCHROME) {
- pars.display = grfx::MonochromeDisplay;
+ case InsetGraphicsParams::MONOCHROME:
+ pars.display = grfx::MonochromeDisplay;
+ break;
- } else if (display == InsetGraphicsParams::GRAYSCALE) {
- pars.display = grfx::GrayscaleDisplay;
+ case InsetGraphicsParams::GRAYSCALE:
+ pars.display = grfx::GrayscaleDisplay;
- } else if (display == InsetGraphicsParams::COLOR) {
- pars.display = grfx::ColorDisplay;
+ case InsetGraphicsParams::COLOR:
+ pars.display = grfx::ColorDisplay;
+ break;
+
+ default: {
+ if (lyxrc.display_graphics == "mono")
+ pars.display = grfx::MonochromeDisplay;
+ else if (lyxrc.display_graphics == "gray")
+ pars.display = grfx::GrayscaleDisplay;
+ else if (lyxrc.display_graphics == "color")
+ pars.display = grfx::ColorDisplay;
+ else
+ pars.display = grfx::NoDisplay;
+ }
}
-
+
// Override the above if we're not using a gui
if (!lyxrc.use_gui) {
pars.display = grfx::NoDisplay;
}
-
+
if (lyxsize_type == InsetGraphicsParams::SCALE) {
pars.scale = lyxscale;
-
+
} else if (lyxsize_type == InsetGraphicsParams::WH) {
- if (!lyxwidth.zero())
- pars.width = lyxwidth.inPixels(1, 1);
- if (!lyxheight.zero())
- pars.height = lyxheight.inPixels(1, 1);
-
- // inPixels returns a value scaled by lyxrc.zoom.
- // We want, therefore, to undo this.
- double const scaling_factor = 100.0 / double(lyxrc.zoom);
- pars.width = uint(scaling_factor * pars.width);
- pars.height = uint(scaling_factor * pars.height);
-
-#if 0
-#warning Angus, could you please adapt this code? (JMarc)
- if (keepLyXAspectRatio) {
- // get the imagesize from the cache
- grfx::Cache & gc = grfx::Cache::get();
- float const rw = gc.raw_width(filename);
- float const rh = gc.raw_height(filename);
- float const ratio = (rw > 0.001) ? rh/rw : 1.0;
- lyxerr[Debug::GRAPHICS]
- << "Value of LyXAspectRatio: "
- << ratio << std::endl;
- if (!lyxwidth.zero() && !lyxheight.zero()) {
- if (width < height)
- height = int(ratio * width);
- else
- width = int(ratio * height);
- } else if (lyxwidth.zero())
- width = int(ratio * height);
- else if (lyxheight.zero())
- height = int(ratio * width);
- }
-#endif
- }
+ pars.width = lyxwidth.inBP();
+ pars.height = lyxheight.inBP();
+ pars.keepLyXAspectRatio = keepLyXAspectRatio;
+ }
return pars;
}
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include "debug.h"
-#include "buffer.h"
-
+#include "toc.h"
using std::vector;
using std::ostream;
{
os << getScreenLabel(buffer) << "\n\n";
- string type;
- string const cmdname = getCmdName();
- if (cmdname == "tableofcontents")
- type = "TOC";
- Buffer::Lists const toc_list = buffer->getLists();
- Buffer::Lists::const_iterator cit =
- toc_list.find(type);
- if (cit != toc_list.end()) {
- Buffer::SingleList::const_iterator ccit = cit->second.begin();
- Buffer::SingleList::const_iterator end = cit->second.end();
- for (; ccit != end; ++ccit)
- os << string(4 * ccit->depth, ' ')
- << ccit->str << "\n";
- }
+ toc::asciiTocList(toc::getType(getCmdName()), buffer, os);
os << "\n";
return 0;
}
if (disable)
- flag.disabled(true);
+ flag.disabled(true);
// A few general toggles
switch (action) {
}
}
+ // this one is difficult to get right. As a half-baked
+ // solution, we consider only the first action of the sequence
+ if (action == LFUN_SEQUENCE) {
+ // argument contains ';'-terminated commands
+ const int ac = lyxaction.LookupFunc(token(argument, ';', 0));
+ flag = getStatus(ac);
+ }
+
return flag;
}
void LyXFunc::dispatch(string const & s, bool verbose)
{
- int const action = lyxaction.LookupFunc(frontStrip(strip(s)));
+ int const action = lyxaction.LookupFunc(s);
if (action == LFUN_UNKNOWN_ACTION) {
string const msg = string(_("Unknown function ("))
+2002-07-21 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * lstrings.h: correct comments for token and tokenPos
+
2002-07-20 Dekel Tsur <dekelts@tau.ac.il>
* lyxstring.C (operator>>): replace code which works only with
Doesn't modify the original string. Similar to strtok.
Example:
\code
- "a;bc;d".token(';', 1) == "bc";
- "a;bc;d".token(';', 2) == "d";
+ token("a;bc;d", ';', 1) == "bc";
+ token("a;bc;d", ';', 2) == "d";
\endcode
*/
string const token(string const & a, char delim, int n);
failure.
Example:
\code
- "a;bc;d".tokenPos(';', "bc") == 1;
- "a;bc;d".token(';', "d") == 2;
+ tokenPos("a;bc;d", ';', "bc") == 1;
+ tokenPos("a;bc;d", ';', "d") == 2;
\endcode
*/
int tokenPos(string const & a, char delim, string const & tok);
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2002 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file toc.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "support/lstrings.h"
+#include "toc.h"
+#include "buffer.h"
+#include "frontends/LyXView.h"
+#include "lyxfunc.h"
+#include "LyXAction.h"
+#include "paragraph.h"
+#include "lyxtextclasslist.h"
+#include "insets/insetfloat.h"
+#include "debug.h"
+
+using std::vector;
+
+extern LyXAction lyxaction;
+
+namespace toc
+{
+
+string const TocItem::asString() const
+{
+ return string(4 * depth, ' ') + str;
+}
+
+
+void TocItem::goTo(LyXView & lv_) const
+{
+ string const tmp = tostr(par->id());
+ lv_.getLyXFunc()->dispatch(LFUN_GOTO_PARAGRAPH, tmp, false);
+}
+
+
+int TocItem::action() const
+{
+ return lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH,
+ tostr(par->id()));
+}
+
+
+string const getType(string const & cmdName)
+{
+ // special case
+ if (cmdName == "tableofcontents")
+ return "TOC";
+ else
+ return cmdName;
+}
+
+
+TocList const getTocList(Buffer const * buf)
+{
+ TocList toclist;
+ Paragraph * par = buf->paragraph;
+
+ LyXTextClass const & textclass = textclasslist[buf->params.textclass];
+ bool found = textclass.hasLayout("Caption");
+ string const layout("Caption");
+
+ while (par) {
+#ifdef WITH_WARNINGS
+#warning bogus type (Lgb)
+#endif
+ char const labeltype = par->layout()->labeltype;
+
+ if (labeltype >= LABEL_COUNTER_CHAPTER
+ && labeltype <= LABEL_COUNTER_CHAPTER + buf->params.tocdepth) {
+ // insert this into the table of contents
+ const int depth = max(0, labeltype - textclass.maxcounter());
+ TocItem const item(par, depth,
+ par->asString(buf, true));
+ toclist["TOC"].push_back(item);
+ }
+ // For each paragraph, traverse its insets and look for
+ // FLOAT_CODE
+
+ if (found) {
+ Paragraph::inset_iterator it =
+ par->inset_iterator_begin();
+ Paragraph::inset_iterator end =
+ par->inset_iterator_end();
+
+ for (; it != end; ++it) {
+ if ((*it)->lyxCode() == Inset::FLOAT_CODE) {
+ InsetFloat * il =
+ static_cast<InsetFloat*>(*it);
+
+ string const type = il->type();
+
+ // Now find the caption in the float...
+ // We now tranverse the paragraphs of
+ // the inset...
+ Paragraph * tmp = il->inset.paragraph();
+ while (tmp) {
+ if (tmp->layout()->name() == layout) {
+ string const str =
+ tostr(toclist[type].size()+1) + ". " + tmp->asString(buf, false);
+ TocItem const item(tmp, 0 , str);
+ toclist[type].push_back(item);
+ }
+ tmp = tmp->next();
+ }
+ }
+ }
+ } else {
+ lyxerr << "Caption not found" << endl;
+ }
+
+ par = par->next();
+ }
+ return toclist;
+}
+
+
+vector<string> const getTypes(Buffer const * buffer)
+{
+ vector<string> types;
+
+ TocList const tmp = getTocList(buffer);
+
+ TocList::const_iterator cit = tmp.begin();
+ TocList::const_iterator end = tmp.end();
+
+ for (; cit != end; ++cit) {
+ types.push_back(cit->first);
+ }
+
+ return types;
+}
+
+
+void asciiTocList(string const & type, Buffer const * buffer, ostream & os)
+{
+ TocList const toc_list = getTocList(buffer);
+ TocList::const_iterator cit = toc_list.find(type);
+ if (cit != toc_list.end()) {
+ Toc::const_iterator ccit = cit->second.begin();
+ Toc::const_iterator end = cit->second.end();
+ for (; ccit != end; ++ccit)
+ os << ccit->asString() << '\n';
+ }
+}
+
+
+} // namespace toc
+
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2002 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file toc.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+ */
+
+#ifndef TOC_H
+#define TOC_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "support/LOstream.h"
+#include "LString.h"
+
+#include <map>
+#include <vector>
+
+class Buffer;
+class LyXView;
+class Paragraph;
+
+/** Nice functions and objects to handle TOCs
+ */
+namespace toc
+{
+
+///
+struct TocItem {
+ TocItem(Paragraph * p, int d, string const & s)
+ : par(p), depth(d), str(s) {}
+ ///
+ string const asString() const;
+ /// set cursor in LyXView to this TocItem
+ void goTo(LyXView & lv_) const;
+ /// the action corresponding to the goTo above
+ int action() const;
+ ///
+ Paragraph * par;
+ ///
+ int depth;
+ ///
+ string str;
+};
+
+///
+typedef std::vector<TocItem> Toc;
+///
+typedef std::map<string, Toc> TocList;
+
+///
+TocList const getTocList(Buffer const *);
+
+///
+std::vector<string> const getTypes(Buffer const *);
+
+///
+void asciiTocList(string const &, Buffer const *, ostream &);
+
+/** Given the cmdName of the TOC param, returns the type used
+ by ControlToc::getContents() */
+string const getType(string const & cmdName);
+
+///
+inline
+bool operator==(TocItem const & a, TocItem const & b)
+{
+ return a.par == b.par && a.str == b.str;
+ // No need to compare depth.
+}
+
+
+///
+inline
+bool operator!=(TocItem const & a, TocItem const & b)
+{
+ return !(a == b);
+ // No need to compare depth.
+}
+
+
+} // namespace toc
+
+#endif // CONTROLTOC_H