mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
dynamic number of lists
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1732 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
42a1e2ea5a
commit
63de5b908f
@ -1,5 +1,14 @@
|
||||
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
|
||||
|
@ -291,7 +291,7 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
|
||||
bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
|
||||
int & pos, char tc)
|
||||
{
|
||||
if (!checkPastePossible(*par, pos))
|
||||
if (!checkPastePossible(*par))
|
||||
return false;
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
@ -537,7 +537,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
|
||||
}
|
||||
|
||||
|
||||
bool CutAndPaste::checkPastePossible(LyXParagraph * par, int)
|
||||
bool CutAndPaste::checkPastePossible(LyXParagraph * par)
|
||||
{
|
||||
if (!buf) return false;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
LyXParagraph * par);
|
||||
///
|
||||
static
|
||||
bool checkPastePossible(LyXParagraph *, int pos);
|
||||
bool checkPastePossible(LyXParagraph *);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
64
src/buffer.C
64
src/buffer.C
@ -16,6 +16,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
@ -3598,14 +3599,14 @@ vector<string> const Buffer::getLabelList()
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -3620,21 +3621,51 @@ vector<vector<Buffer::TocItem> > const Buffer::getTocList() const
|
||||
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;
|
||||
@ -3655,8 +3686,29 @@ vector<vector<Buffer::TocItem> > const Buffer::getTocList() const
|
||||
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_;
|
||||
|
11
src/buffer.h
11
src/buffer.h
@ -262,7 +262,7 @@ public:
|
||||
///
|
||||
string const getIncludeonlyList(char delim = ',');
|
||||
///
|
||||
std::vector<std::pair<string,string> > const getBibkeyList();
|
||||
std::vector<std::pair<string, string> > const getBibkeyList();
|
||||
///
|
||||
struct TocItem {
|
||||
///
|
||||
@ -272,15 +272,8 @@ public:
|
||||
///
|
||||
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();
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
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:
|
||||
|
@ -67,9 +67,19 @@ void FormToc::build()
|
||||
{
|
||||
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
|
||||
@ -84,6 +94,7 @@ void FormToc::build()
|
||||
|
||||
void FormToc::update()
|
||||
{
|
||||
#if 0
|
||||
Buffer::TocType type;
|
||||
|
||||
if (params.getCmdName() == "tableofcontents" )
|
||||
@ -99,13 +110,16 @@ void FormToc::update()
|
||||
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 );
|
||||
@ -150,6 +164,62 @@ void FormToc::updateToc()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,6 +309,7 @@ void add_toc2(int menu, string const & extra_label,
|
||||
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
|
||||
@ -358,7 +359,49 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
|
||||
|
||||
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,
|
||||
|
@ -1,5 +1,7 @@
|
||||
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
|
||||
|
||||
|
@ -53,6 +53,7 @@ int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const
|
||||
{
|
||||
os << getScreenLabel() << endl << endl;
|
||||
|
||||
#if 0
|
||||
Buffer::TocType type;
|
||||
string cmdname = getCmdName();
|
||||
if (cmdname == "tableofcontents" )
|
||||
@ -70,7 +71,33 @@ int InsetTOC::Ascii(Buffer const * buffer, ostream & os, int) const
|
||||
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;
|
||||
}
|
||||
|
@ -2374,7 +2374,7 @@ void LyXText::PasteSelection(BufferView * bview)
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user