2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+ * buffer.h: remove TocType
+
+ * buffer.C (getTocList): change to return a map<string,
+ vector<TocItem> >, implement for dynamic number of list.
+
+ * CutAndPaste.[Ch] (checkPastePossible): remove unused arg
+ * text2.C (PasteSelection): adjust
+ * CutAndPaste.C (pasteSelection): adjust
+
* FloatList.C (FloatList): update from the new_insets branch.
* Floating.[Ch]: ditto
* LaTeXFeatures.C: ditto
bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
int & pos, char tc)
{
- if (!checkPastePossible(*par, pos))
+ if (!checkPastePossible(*par))
return false;
#ifndef NEW_INSETS
}
-bool CutAndPaste::checkPastePossible(LyXParagraph * par, int)
+bool CutAndPaste::checkPastePossible(LyXParagraph * par)
{
if (!buf) return false;
LyXParagraph * par);
///
static
- bool checkPastePossible(LyXParagraph *, int pos);
+ bool checkPastePossible(LyXParagraph *);
};
#endif
#include <fstream>
#include <iomanip>
+#include <map>
#include <cstdlib>
#include <cmath>
}
-vector<vector<Buffer::TocItem> > const Buffer::getTocList() const
+map<string, vector<Buffer::TocItem> > const Buffer::getTocList() const
{
#ifndef NEW_INSETS
int figs = 0;
int tables = 0;
int algs = 0;
#endif
- vector<vector<TocItem> > l(4);
+ map<string, vector<TocItem> > l;
LyXParagraph * par = paragraph;
while (par) {
#ifndef NEW_INSETS
switch (par->footnotekind) {
case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG:
+ {
tmp.str = tostr(++figs) + ". "
+ tmp.str;
- l[TOC_LOF].push_back(tmp);
+ map<string, vector<TocItem> >::iterator it = l.find("LOF");
+ if (it == l.end()) {
+ vector<TocItem> vti;
+ vti.push_back(tmp);
+ l["LOF"] = vti;
+ } else {
+ it->second.push_back(tmp);
+ }
break;
+ }
+
case LyXParagraph::TAB:
case LyXParagraph::WIDE_TAB:
+ {
tmp.str = tostr(++tables) + ". "
+ tmp.str;
- l[TOC_LOT].push_back(tmp);
+ map<string, vector<TocItem> >::iterator it = l.find("LOT");
+ if (it == l.end()) {
+ vector<TocItem> vti;
+ vti.push_back(tmp);
+ l["LOT"] = vti;
+ } else {
+ it->second.push_back(tmp);
+ }
break;
+ }
+
case LyXParagraph::ALGORITHM:
+ {
tmp.str = tostr(++algs) + ". "
+ tmp.str;
- l[TOC_LOA].push_back(tmp);
+ map<string, vector<TocItem> >::iterator it = l.find("LOA");
+ if (it == l.end()) {
+ vector<TocItem> vti;
+ vti.push_back(tmp);
+ l["LOA"] = vti;
+ } else {
+ it->second.push_back(tmp);
+ }
break;
+ }
+
case LyXParagraph::FOOTNOTE:
case LyXParagraph::MARGIN:
break;
labeltype -
textclasslist.TextClass(params.textclass).maxcounter());
tmp.str = par->String(this, true);
- l[TOC_TOC].push_back(tmp);
+ map<string, vector<TocItem> >::iterator it = l.find("TOC");
+ if (it == l.end()) {
+ vector<TocItem> vti;
+ vti.push_back(tmp);
+ l["TOC"] = vti;
+ } else {
+ it->second.push_back(tmp);
+ }
}
+#ifdef NEW_INSETS
+ // For each paragrph, traverse its insets and look for
+ // FLOAT_CODE
+ LyXParagraph::inset_iterator it =
+ par->inset_iterator_begin();
+ LyXParagraph::inset_iterator end =
+ par->inset_iterator_end();
+ for (; it != end; ++it) {
+ if ((*it)->LyxCode() == Inset::FLOAT_CODE) {
+ lyxerr << "Found a float!" << endl;
+ // Now find the caption in the float...
+ }
+ }
+#endif
#ifndef NEW_INSETS
}
par = par->next_;
///
string const getIncludeonlyList(char delim = ',');
///
- std::vector<std::pair<string,string> > const getBibkeyList();
+ std::vector<std::pair<string, string> > const getBibkeyList();
///
struct TocItem {
///
///
string str;
};
- /// The different content list types.
- enum TocType {
- TOC_TOC = 0, ///< Table of Contents
- TOC_LOF, ///< List of Figures
- TOC_LOT, ///< List of Tables
- TOC_LOA ///< List of Algorithms
- };
///
- std::vector<std::vector<TocItem> > const getTocList() const;
+ std::map<string, std::vector<TocItem> > const getTocList() const;
///
std::vector<string> const getLabelList();
+2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+
+ * FormToc.C (build): implement for dynamic number of lists
+ (updateToc): ditto
+ * Menubar_pimpl.C (add_toc): ditto
+
2001-03-07 Edwin Leuven <leuven@fee.uva.nl>
* added credits:
{
dialog_ = build_toc();
+#if 0
fl_addto_choice(dialog_->choice_toc_type,
_(" TOC | LOF | LOT | LOA "));
-
+#else
+ map<string, vector<Buffer::TocItem> > tmp =
+ lv_->view()->buffer()->getTocList();
+ string types;
+ map<string, vector<Buffer::TocItem> >::const_iterator cit = tmp.begin();
+ map<string, vector<Buffer::TocItem> >::const_iterator end = tmp.end();
+ for (; cit != end; ++cit) {
+ fl_addto_choice(dialog_->choice_toc_type, cit->first.c_str());
+ }
+#endif
// Don't need to limit size of this dialog
// (but fixing min size is a GOOD thing).
// Workaround dumb xforms sizing bug
void FormToc::update()
{
+#if 0
Buffer::TocType type;
if (params.getCmdName() == "tableofcontents" )
type = Buffer::TOC_LOT;
fl_set_choice( dialog_->choice_toc_type, type+1 );
-
+#else
+#warning Reimplement (Lgb)
+#endif
updateToc();
}
void FormToc::updateToc()
{
+#if 0
if (!lv_->view()->available()) {
toclist.clear();
fl_clear_browser( dialog_->browser_toc );
fl_set_browser_topline( dialog_->browser_toc, topline );
fl_select_browser_line( dialog_->browser_toc, line );
+#else
+#warning Fix Me! (Lgb)
+ if (!lv_->view()->available()) {
+ toclist.clear();
+ fl_clear_browser( dialog_->browser_toc );
+ fl_add_browser_line( dialog_->browser_toc,
+ _("*** No Document ***"));
+ return;
+ }
+
+ map<string, vector<Buffer::TocItem> > tmp =
+ lv_->view()->buffer()->getTocList();
+ //int type = fl_get_choice( dialog_->choice_toc_type ) - 1;
+ string type = fl_get_choice_item_text(dialog_->choice_toc_type,
+ fl_get_choice(dialog_->choice_toc_type));
+
+ map<string, vector<Buffer::TocItem> >::iterator it = tmp.find(type);
+
+ if (it != tmp.end()) {
+ // Check if all elements are the same.
+ if (toclist == it->second) {
+ return;
+ }
+ } else if (it == tmp.end()) {
+ toclist.clear();
+ fl_clear_browser(dialog_->browser_toc);
+ fl_add_browser_line(dialog_->browser_toc,
+ _("*** No Lists ***"));
+ return;
+ }
+
+ // List has changed. Update browser
+ toclist = it->second;
+
+ static Buffer * buffer = 0;
+ int topline = 0;
+ int line = 0;
+ if (buffer == lv_->view()->buffer()) {
+ topline = fl_get_browser_topline(dialog_->browser_toc);
+ line = fl_get_browser( dialog_->browser_toc );
+ } else
+ buffer = lv_->view()->buffer();
+
+ fl_clear_browser(dialog_->browser_toc);
+
+ vector<Buffer::TocItem>::const_iterator cit = toclist.begin();
+ vector<Buffer::TocItem>::const_iterator end = toclist.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_set_browser_topline(dialog_->browser_toc, topline);
+ fl_select_browser_line(dialog_->browser_toc, line);
+#endif
}
void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
vector<int> & smn, Window win)
{
+#if 0
//xgettext:no-c-format
static char const * MenuNames[3] = { N_("List of Figures%m"),
//xgettext:no-c-format
add_toc2(menu, extra_label, smn, win,
toc_list[0], 0, toc_list[0].size(), 0);
+#else
+#warning Fix Me! (Lgb)
+ map<string, vector<Buffer::TocItem> > toc_list =
+ owner_->buffer()->getTocList();
+ map<string, vector<Buffer::TocItem> >::const_iterator cit =
+ toc_list.begin();
+ map<string, vector<Buffer::TocItem> >::const_iterator end =
+ toc_list.end();
+ for (; cit != end; ++cit) {
+ // Handle this elsewhere
+ if (cit->first == "TOC") continue;
+
+ int menu2 = get_new_submenu(smn, win);
+ vector<Buffer::TocItem>::const_iterator ccit =
+ cit->second.begin();
+ vector<Buffer::TocItem>::const_iterator eend =
+ cit->second.end();
+ for (; ccit != eend; ++ccit) {
+ int const action = lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH, tostr(ccit->par->id()));
+ string label = fixlabel(ccit->str);
+ label = limit_string_length(label);
+ label += "%x" + tostr(action + action_offset);
+ fl_addtopup(menu2, label.c_str());
+ lyxerr << "[" << cit->first << "] " << label << endl;
+ }
+ string const m = cit->first + "%m";
+ fl_addtopup(menu, m.c_str(), menu2);
+ }
+
+
+ // Handle normal TOC
+ cit = toc_list.find("TOC");
+ if (cit == end) {
+ string const tmp = _("No Table of contents%i") + extra_label;
+ fl_addtopup(menu, tmp.c_str());
+ return;
+ } else {
+ add_toc2(menu, extra_label, smn, win,
+ cit->second, 0, cit->second.size(), 0);
+ }
+
+#endif
}
int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+ * insettoc.C (Ascii): implement for dynamic number of lists
+
* insetcaption.[Ch]: update from new_insets branch
* insetfloat.[Ch]: ditto
{
os << getScreenLabel() << endl << endl;
+#if 0
Buffer::TocType type;
string cmdname = getCmdName();
if (cmdname == "tableofcontents" )
for (vector<Buffer::TocItem>::const_iterator it = toc.begin();
it != toc.end(); ++it)
os << string(4 * it->depth, ' ') << it->str << endl;
+#else
+#warning Fix Me! (Lgb)
+ string type;
+ string cmdname = getCmdName();
+ if (cmdname == "tableofcontents" )
+ type = "TOC";
+ else if (cmdname == "listofalgorithms" )
+ type = "LOA";
+ else if (cmdname == "listoffigures" )
+ type = "LOF";
+ else
+ type = "LOT";
+ map<string, vector<Buffer::TocItem> > const toc_list =
+ buffer->getTocList();
+ map<string, vector<Buffer::TocItem> >::const_iterator cit =
+ toc_list.find(type);
+ if (cit != toc_list.end()) {
+ vector<Buffer::TocItem>::const_iterator ccit =
+ cit->second.begin();
+ vector<Buffer::TocItem>::const_iterator end =
+ cit->second.end();
+ for (; ccit != end; ++ccit)
+ os << string(4 * ccit->depth, ' ')
+ << ccit->str << endl;
+ }
+#endif
os << endl;
return 0;
}
CutAndPaste cap;
// this does not make sense, if there is nothing to paste
- if (!cap.checkPastePossible(cursor.par(), cursor.pos()))
+ if (!cap.checkPastePossible(cursor.par()))
return;
SetUndo(bview->buffer(), Undo::INSERT,