mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Controller-view split of Graphics and Index popups.
Moved Citation and Character helper functions into their own namespaces. Fixed bugs in Minipage controller. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1843 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
39447abc2d
commit
cda84cbcdf
@ -1,9 +1,46 @@
|
|||||||
|
2001-03-28 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
|
* ControlInset.h (clearDaughterParams): is empty by default, not pure.
|
||||||
|
(setDaughterParams): a (by default empty) new method called in show().
|
||||||
|
|
||||||
|
* ControlBibitem.h:
|
||||||
|
* ControlBibtex.h:
|
||||||
|
* ControlError.h:
|
||||||
|
* ControlInclude.h:
|
||||||
|
* ControlMinipage.h:
|
||||||
|
* ControlRef.h:
|
||||||
|
* ControlSearch.h:
|
||||||
|
* ControlUrl.h (clearDaughterParams): removed
|
||||||
|
|
||||||
|
* ControlMinipage.C (applyParamsToInset): update the view.
|
||||||
|
Added namespace minipage containing a helper function getUnits.
|
||||||
|
|
||||||
|
* GUI.h: changed Minipage policy to NoRepeatedApplyReadOnlyPolicy.
|
||||||
|
|
||||||
|
* ControlCharacter.[Ch]: moved out all the helper functions and the
|
||||||
|
enum into their own file.
|
||||||
|
* character.[Ch]: new files; contain the character helper functions,
|
||||||
|
now inside namespace character.
|
||||||
|
|
||||||
|
* ControlCitation.[Ch]: moved out all the helper functions and the
|
||||||
|
enums into their own file. Simplified interface.
|
||||||
|
* biblio.[Ch]: new files; contain the citation helper functions,
|
||||||
|
now inside namespace biblio. Will be of use also to an improved
|
||||||
|
BibTeX popup.
|
||||||
|
|
||||||
|
* ControlGraphics.[Ch]:
|
||||||
|
* ControlIndex.[Ch]: new files; controllers for the Graphics and Index
|
||||||
|
popups, respectively.
|
||||||
|
|
||||||
|
* GUI.h:
|
||||||
|
* Makefile.am: associated changes.
|
||||||
|
|
||||||
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
|
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* ControlMinipage.[Ch]:
|
* ControlMinipage.[Ch]:
|
||||||
* ControlPreamble.[Ch]:
|
* ControlPreamble.[Ch]:
|
||||||
* ControlPrint.[Ch]:
|
* ControlPrint.[Ch]:
|
||||||
* ControlSplash.[Ch]: new files; controller for the Minipage, Preamble
|
* ControlSplash.[Ch]: new files; controllers for the Minipage, Preamble
|
||||||
and Print popups and Splash screen, respectively.
|
and Print popups and Splash screen, respectively.
|
||||||
|
|
||||||
* ViewBase.h (ViewSplash): new base class for GUI-specific Splash
|
* ViewBase.h (ViewSplash): new base class for GUI-specific Splash
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
/** A controller for Bibitem dialogs.
|
/** A controller for Bibitem dialogs.
|
||||||
*/
|
*/
|
||||||
class ControlBibitem : public ControlCommand
|
class ControlBibitem : public ControlCommand {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
ControlBibitem(LyXView &, Dialogs &);
|
ControlBibitem(LyXView &, Dialogs &);
|
||||||
@ -34,8 +33,6 @@ private:
|
|||||||
virtual void applyParamsToInset();
|
virtual void applyParamsToInset();
|
||||||
/// not needed.
|
/// not needed.
|
||||||
virtual void applyParamsNoInset() {}
|
virtual void applyParamsNoInset() {}
|
||||||
/// not needed.
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLBIBITEM_H
|
#endif // CONTROLBIBITEM_H
|
||||||
|
@ -35,8 +35,6 @@ private:
|
|||||||
virtual void applyParamsToInset();
|
virtual void applyParamsToInset();
|
||||||
///
|
///
|
||||||
virtual void applyParamsNoInset();
|
virtual void applyParamsNoInset();
|
||||||
/// not needed.
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLBIBTEX_H
|
#endif // CONTROLBIBTEX_H
|
||||||
|
@ -15,13 +15,11 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "ControlCharacter.h"
|
#include "ControlCharacter.h"
|
||||||
#include "bufferview_funcs.h"
|
#include "buffer.h"
|
||||||
#include "Dialogs.h"
|
#include "Dialogs.h"
|
||||||
#include "Liason.h"
|
#include "Liason.h"
|
||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
#include "buffer.h"
|
#include "bufferview_funcs.h" // ToggleAndShow
|
||||||
#include "lyxtext.h"
|
|
||||||
#include "language.h"
|
|
||||||
|
|
||||||
using Liason::setMinibuffer;
|
using Liason::setMinibuffer;
|
||||||
using SigC::slot;
|
using SigC::slot;
|
||||||
@ -86,33 +84,33 @@ void ControlCharacter::setSize(LyXFont::FONT_SIZE val)
|
|||||||
font_->setSize(val);
|
font_->setSize(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlCharacter::setBar(ControlCharacter::FONT_STATE val)
|
void ControlCharacter::setBar(character::FONT_STATE val)
|
||||||
{
|
{
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case IGNORE:
|
case character::IGNORE:
|
||||||
font_->setEmph(LyXFont::IGNORE);
|
font_->setEmph(LyXFont::IGNORE);
|
||||||
font_->setUnderbar(LyXFont::IGNORE);
|
font_->setUnderbar(LyXFont::IGNORE);
|
||||||
font_->setNoun(LyXFont::IGNORE);
|
font_->setNoun(LyXFont::IGNORE);
|
||||||
font_->setLatex(LyXFont::IGNORE);
|
font_->setLatex(LyXFont::IGNORE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMPH_TOGGLE:
|
case character::EMPH_TOGGLE:
|
||||||
font_->setEmph(LyXFont::TOGGLE);
|
font_->setEmph(LyXFont::TOGGLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNDERBAR_TOGGLE:
|
case character::UNDERBAR_TOGGLE:
|
||||||
font_->setUnderbar(LyXFont::TOGGLE);
|
font_->setUnderbar(LyXFont::TOGGLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOUN_TOGGLE:
|
case character::NOUN_TOGGLE:
|
||||||
font_->setNoun(LyXFont::TOGGLE);
|
font_->setNoun(LyXFont::TOGGLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LATEX_TOGGLE:
|
case character::LATEX_TOGGLE:
|
||||||
font_->setLatex(LyXFont::TOGGLE);
|
font_->setLatex(LyXFont::TOGGLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INHERIT:
|
case character::INHERIT:
|
||||||
font_->setEmph(LyXFont::INHERIT);
|
font_->setEmph(LyXFont::INHERIT);
|
||||||
font_->setUnderbar(LyXFont::INHERIT);
|
font_->setUnderbar(LyXFont::INHERIT);
|
||||||
font_->setNoun(LyXFont::INHERIT);
|
font_->setNoun(LyXFont::INHERIT);
|
||||||
@ -160,172 +158,3 @@ void ControlCharacter::setToggleAll(bool t)
|
|||||||
{
|
{
|
||||||
toggleall_ = t;
|
toggleall_ = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::FamilyPair> const getFamilyData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::FamilyPair> family(5);
|
|
||||||
|
|
||||||
ControlCharacter::FamilyPair pr;
|
|
||||||
pr.first = _("No change"); pr.second = LyXFont::IGNORE_FAMILY;
|
|
||||||
family[0] = pr;
|
|
||||||
pr.first = _("Roman"); pr.second = LyXFont::ROMAN_FAMILY;
|
|
||||||
family[1] = pr;
|
|
||||||
pr.first = _("Sans Serif"); pr.second = LyXFont::SANS_FAMILY;
|
|
||||||
family[2] = pr;
|
|
||||||
pr.first = _("Typewriter"); pr.second = LyXFont::TYPEWRITER_FAMILY;
|
|
||||||
family[3] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_FAMILY;
|
|
||||||
family[4] = pr;
|
|
||||||
|
|
||||||
return family;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::SeriesPair> const getSeriesData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::SeriesPair> series(4);
|
|
||||||
|
|
||||||
ControlCharacter::SeriesPair pr;
|
|
||||||
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SERIES;
|
|
||||||
series[0] = pr;
|
|
||||||
pr.first = _("Medium"); pr.second = LyXFont::MEDIUM_SERIES;
|
|
||||||
series[1] = pr;
|
|
||||||
pr.first = _("Bold"); pr.second = LyXFont::BOLD_SERIES;
|
|
||||||
series[2] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SERIES;
|
|
||||||
series[3] = pr;
|
|
||||||
|
|
||||||
return series;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::ShapePair> const getShapeData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::ShapePair> shape(6);
|
|
||||||
|
|
||||||
ControlCharacter::ShapePair pr;
|
|
||||||
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SHAPE;
|
|
||||||
shape[0] = pr;
|
|
||||||
pr.first = _("Upright"); pr.second = LyXFont::UP_SHAPE;
|
|
||||||
shape[1] = pr;
|
|
||||||
pr.first = _("Italic"); pr.second = LyXFont::ITALIC_SHAPE;
|
|
||||||
shape[2] = pr;
|
|
||||||
pr.first = _("Slanted"); pr.second = LyXFont::SLANTED_SHAPE;
|
|
||||||
shape[3] = pr;
|
|
||||||
pr.first = _("Small Caps"); pr.second = LyXFont::SMALLCAPS_SHAPE;
|
|
||||||
shape[4] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SHAPE;
|
|
||||||
shape[5] = pr;
|
|
||||||
|
|
||||||
return shape;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::SizePair> const getSizeData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::SizePair> size(14);
|
|
||||||
|
|
||||||
ControlCharacter::SizePair pr;
|
|
||||||
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SIZE;
|
|
||||||
size[0] = pr;
|
|
||||||
pr.first = _("Tiny"); pr.second = LyXFont::SIZE_TINY;
|
|
||||||
size[1] = pr;
|
|
||||||
pr.first = _("Smallest"); pr.second = LyXFont::SIZE_SCRIPT;
|
|
||||||
size[2] = pr;
|
|
||||||
pr.first = _("Smaller"); pr.second = LyXFont::SIZE_FOOTNOTE;
|
|
||||||
size[3] = pr;
|
|
||||||
pr.first = _("Small"); pr.second = LyXFont::SIZE_SMALL;
|
|
||||||
size[4] = pr;
|
|
||||||
pr.first = _("Normal"); pr.second = LyXFont::SIZE_NORMAL;
|
|
||||||
size[5] = pr;
|
|
||||||
pr.first = _("Large"); pr.second = LyXFont::SIZE_LARGE;
|
|
||||||
size[6] = pr;
|
|
||||||
pr.first = _("Larger"); pr.second = LyXFont::SIZE_LARGER;
|
|
||||||
size[7] = pr;
|
|
||||||
pr.first = _("Largest"); pr.second = LyXFont::SIZE_LARGEST;
|
|
||||||
size[8] = pr;
|
|
||||||
pr.first = _("Huge"); pr.second = LyXFont::SIZE_HUGE;
|
|
||||||
size[9] = pr;
|
|
||||||
pr.first = _("Huger"); pr.second = LyXFont::SIZE_HUGER;
|
|
||||||
size[10] = pr;
|
|
||||||
pr.first = _("Increase"); pr.second = LyXFont::INCREASE_SIZE;
|
|
||||||
size[11] = pr;
|
|
||||||
pr.first = _("Decrease"); pr.second = LyXFont::DECREASE_SIZE;
|
|
||||||
size[12] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SIZE;
|
|
||||||
size[13] = pr;
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::BarPair> const getBarData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::BarPair> bar(6);
|
|
||||||
|
|
||||||
ControlCharacter::BarPair pr;
|
|
||||||
pr.first = _("No change"); pr.second = ControlCharacter::IGNORE;
|
|
||||||
bar[0] = pr;
|
|
||||||
pr.first = _("Emph"); pr.second = ControlCharacter::EMPH_TOGGLE;
|
|
||||||
bar[1] = pr;
|
|
||||||
pr.first = _("Underbar"); pr.second = ControlCharacter::UNDERBAR_TOGGLE;
|
|
||||||
bar[2] = pr;
|
|
||||||
pr.first = _("Noun"); pr.second = ControlCharacter::NOUN_TOGGLE;
|
|
||||||
bar[3] = pr;
|
|
||||||
pr.first = _("LaTeX mode"); pr.second = ControlCharacter::LATEX_TOGGLE;
|
|
||||||
bar[4] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = ControlCharacter::INHERIT;
|
|
||||||
bar[5] = pr;
|
|
||||||
|
|
||||||
return bar;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<ControlCharacter::ColorPair> const getColorData()
|
|
||||||
{
|
|
||||||
vector<ControlCharacter::ColorPair> color(11);
|
|
||||||
|
|
||||||
ControlCharacter::ColorPair pr;
|
|
||||||
pr.first = _("No change"); pr.second = LColor::ignore;
|
|
||||||
color[0] = pr;
|
|
||||||
pr.first = _("No color"); pr.second = LColor::none;
|
|
||||||
color[1] = pr;
|
|
||||||
pr.first = _("Black"); pr.second = LColor::black;
|
|
||||||
color[2] = pr;
|
|
||||||
pr.first = _("White"); pr.second = LColor::white;
|
|
||||||
color[3] = pr;
|
|
||||||
pr.first = _("Red"); pr.second = LColor::red;
|
|
||||||
color[4] = pr;
|
|
||||||
pr.first = _("Green"); pr.second = LColor::green;
|
|
||||||
color[5] = pr;
|
|
||||||
pr.first = _("Blue"); pr.second = LColor::blue;
|
|
||||||
color[6] = pr;
|
|
||||||
pr.first = _("Cyan"); pr.second = LColor::cyan;
|
|
||||||
color[7] = pr;
|
|
||||||
pr.first = _("Magenta"); pr.second = LColor::magenta;
|
|
||||||
color[8] = pr;
|
|
||||||
pr.first = _("Yellow"); pr.second = LColor::yellow;
|
|
||||||
color[9] = pr;
|
|
||||||
pr.first = _("Reset"); pr.second = LColor::inherit;
|
|
||||||
color[10] = pr;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> const getLanguageData()
|
|
||||||
{
|
|
||||||
vector<string> langs(languages.size() + 2);
|
|
||||||
|
|
||||||
langs[0] = _("No change");
|
|
||||||
langs[1] = _("Reset");
|
|
||||||
|
|
||||||
vector<string>::size_type i = 1;
|
|
||||||
for (Languages::const_iterator cit = languages.begin();
|
|
||||||
cit != languages.end(); ++cit) {
|
|
||||||
langs[++i] = cit->second.lang();
|
|
||||||
}
|
|
||||||
|
|
||||||
return langs;
|
|
||||||
}
|
|
||||||
|
@ -14,43 +14,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ControlDialogs.h"
|
#include "ControlDialogs.h"
|
||||||
#include "lyxfont.h"
|
#include "character.h"
|
||||||
#include "LColor.h"
|
|
||||||
|
|
||||||
/** A controller for Character dialogs.
|
/** A controller for Character dialogs.
|
||||||
*/
|
*/
|
||||||
class ControlCharacter : public ControlDialog<ControlConnectBD>
|
class ControlCharacter : public ControlDialog<ControlConnectBD>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
|
||||||
enum FONT_STATE {
|
|
||||||
///
|
|
||||||
IGNORE,
|
|
||||||
///
|
|
||||||
EMPH_TOGGLE,
|
|
||||||
///
|
|
||||||
UNDERBAR_TOGGLE,
|
|
||||||
///
|
|
||||||
NOUN_TOGGLE,
|
|
||||||
///
|
|
||||||
LATEX_TOGGLE,
|
|
||||||
///
|
|
||||||
INHERIT
|
|
||||||
};
|
|
||||||
|
|
||||||
///
|
|
||||||
typedef std::pair<string, LyXFont::FONT_FAMILY> FamilyPair;
|
|
||||||
///
|
|
||||||
typedef std::pair<string, LyXFont::FONT_SERIES> SeriesPair;
|
|
||||||
///
|
|
||||||
typedef std::pair<string, LyXFont::FONT_SHAPE> ShapePair;
|
|
||||||
///
|
|
||||||
typedef std::pair<string, LyXFont::FONT_SIZE> SizePair;
|
|
||||||
///
|
|
||||||
typedef std::pair<string, FONT_STATE> BarPair;
|
|
||||||
///
|
|
||||||
typedef std::pair<string, LColor::color> ColorPair;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
ControlCharacter(LyXView &, Dialogs &);
|
ControlCharacter(LyXView &, Dialogs &);
|
||||||
|
|
||||||
@ -63,7 +33,7 @@ public:
|
|||||||
///
|
///
|
||||||
void setSize(LyXFont::FONT_SIZE);
|
void setSize(LyXFont::FONT_SIZE);
|
||||||
///
|
///
|
||||||
void setBar(FONT_STATE);
|
void setBar(character::FONT_STATE);
|
||||||
///
|
///
|
||||||
void setColor(LColor::color);
|
void setColor(LColor::color);
|
||||||
///
|
///
|
||||||
@ -85,19 +55,4 @@ private:
|
|||||||
bool toggleall_;
|
bool toggleall_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper functions
|
|
||||||
std::vector<ControlCharacter::FamilyPair> const getFamilyData();
|
|
||||||
///
|
|
||||||
std::vector<ControlCharacter::SeriesPair> const getSeriesData();
|
|
||||||
///
|
|
||||||
std::vector<ControlCharacter::ShapePair> const getShapeData();
|
|
||||||
///
|
|
||||||
std::vector<ControlCharacter::SizePair> const getSizeData();
|
|
||||||
///
|
|
||||||
std::vector<ControlCharacter::BarPair> const getBarData();
|
|
||||||
///
|
|
||||||
std::vector<ControlCharacter::ColorPair> const getColorData();
|
|
||||||
///
|
|
||||||
std::vector<string> const getLanguageData();
|
|
||||||
|
|
||||||
#endif // CONTROLCHARACTER_H
|
#endif // CONTROLCHARACTER_H
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/* This file is part of
|
/* This file is part of
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -24,15 +23,9 @@
|
|||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "Dialogs.h"
|
#include "Dialogs.h"
|
||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
#include "helper_funcs.h"
|
|
||||||
#include "support/lstrings.h"
|
|
||||||
#include "support/LRegex.h"
|
|
||||||
|
|
||||||
using std::find;
|
|
||||||
using std::min;
|
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::sort;
|
|
||||||
using SigC::slot;
|
using SigC::slot;
|
||||||
|
|
||||||
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
|
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
|
||||||
@ -51,291 +44,21 @@ void ControlCitation::clearDaughterParams()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// A functor for use with std::sort, leading to case insensitive sorting
|
void ControlCitation::setDaughterParams()
|
||||||
struct compareNoCase: public std::binary_function<string, string, bool>
|
|
||||||
{
|
{
|
||||||
bool operator()(string const & s1, string const & s2) const {
|
|
||||||
return compare_no_case(s1, s2) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
vector<string> const ControlCitation::getBibkeys()
|
|
||||||
{
|
|
||||||
vector<string> bibkeys;
|
|
||||||
bibkeysInfo_.clear();
|
|
||||||
|
|
||||||
vector<pair<string,string> > blist = lv_.buffer()->getBibkeyList();
|
vector<pair<string,string> > blist = lv_.buffer()->getBibkeyList();
|
||||||
|
|
||||||
|
typedef std::map<string, string>::value_type InfoMapValue;
|
||||||
|
|
||||||
for (vector<pair<string,string> >::size_type i=0; i<blist.size(); ++i) {
|
for (vector<pair<string,string> >::size_type i=0; i<blist.size(); ++i) {
|
||||||
bibkeys.push_back(blist[i].first);
|
|
||||||
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
|
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
|
||||||
blist[i].second));
|
blist[i].second));
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
|
|
||||||
return bibkeys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ControlCitation::getBibkeyInfo(string const & key)
|
biblio::InfoMap const & ControlCitation::bibkeysInfo() const
|
||||||
{
|
{
|
||||||
Assert(!bibkeysInfo_.empty());
|
Assert(!bibkeysInfo_.empty());
|
||||||
|
return bibkeysInfo_;
|
||||||
string result;
|
|
||||||
|
|
||||||
InfoMap::const_iterator it = bibkeysInfo_.find(key);
|
|
||||||
if (it != bibkeysInfo_.end()) {
|
|
||||||
// Search for all possible "required" keys
|
|
||||||
string author = parseBibTeX(it->second, "author");
|
|
||||||
if (author.empty())
|
|
||||||
author = parseBibTeX(it->second, "editor");
|
|
||||||
|
|
||||||
string year = parseBibTeX(it->second, "year");
|
|
||||||
string title = parseBibTeX(it->second, "title");
|
|
||||||
string booktitle = parseBibTeX(it->second, "booktitle");
|
|
||||||
string chapter = parseBibTeX(it->second, "chapter");
|
|
||||||
string pages = parseBibTeX(it->second, "pages");
|
|
||||||
|
|
||||||
string media = parseBibTeX(it->second, "journal");
|
|
||||||
if (media.empty())
|
|
||||||
media = parseBibTeX(it->second, "publisher");
|
|
||||||
if (media.empty())
|
|
||||||
media = parseBibTeX(it->second, "school");
|
|
||||||
if (media.empty())
|
|
||||||
media = parseBibTeX(it->second, "institution");
|
|
||||||
|
|
||||||
result = author;
|
|
||||||
if (!year.empty())
|
|
||||||
result += ", " + year;
|
|
||||||
if (!title.empty())
|
|
||||||
result += ", " + title;
|
|
||||||
if (!booktitle.empty())
|
|
||||||
result += ", in " + booktitle;
|
|
||||||
if (!chapter.empty())
|
|
||||||
result += ", Ch. " + chapter;
|
|
||||||
if (!media.empty())
|
|
||||||
result += ", " + media;
|
|
||||||
if (!pages.empty())
|
|
||||||
result += ", pp. " + pages;
|
|
||||||
|
|
||||||
if (result.empty()) // not a BibTeX record
|
|
||||||
result = it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::const_iterator
|
|
||||||
searchKeys(ControlCitation const & controller,
|
|
||||||
vector<string> const & keys,
|
|
||||||
string const & expr,
|
|
||||||
vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Search type,
|
|
||||||
ControlCitation::Direction dir,
|
|
||||||
bool caseSensitive)
|
|
||||||
{
|
|
||||||
// Preliminary checks
|
|
||||||
if(start < keys.begin() || start >= keys.end())
|
|
||||||
return keys.end();
|
|
||||||
|
|
||||||
string search_expr = frontStrip(strip(expr));
|
|
||||||
if (search_expr.empty())
|
|
||||||
return start;
|
|
||||||
|
|
||||||
if (type == ControlCitation::SIMPLE)
|
|
||||||
return simpleSearch(controller, keys, search_expr, start, dir,
|
|
||||||
caseSensitive);
|
|
||||||
|
|
||||||
return regexSearch(controller, keys, search_expr, start, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::const_iterator
|
|
||||||
simpleSearch(ControlCitation const & controller,
|
|
||||||
vector<string> const & keys,
|
|
||||||
string const & expr,
|
|
||||||
vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Direction dir,
|
|
||||||
bool caseSensitive)
|
|
||||||
{
|
|
||||||
vector<string> searchwords = getVectorFromString(expr, " ");
|
|
||||||
|
|
||||||
// Loop over all keys from start...
|
|
||||||
for (vector<string>::const_iterator it = start;
|
|
||||||
// End condition is direction-dependent.
|
|
||||||
(dir == ControlCitation::FORWARD) ?
|
|
||||||
(it<keys.end()) : (it>=keys.begin());
|
|
||||||
// increment is direction-dependent.
|
|
||||||
(dir == ControlCitation::FORWARD) ?
|
|
||||||
(++it) : (--it)) {
|
|
||||||
|
|
||||||
string data = (*it);
|
|
||||||
ControlCitation::InfoMap::const_iterator info =
|
|
||||||
controller.bibkeysInfo().find(*it);
|
|
||||||
if (info != controller.bibkeysInfo().end())
|
|
||||||
data += " " + info->second;
|
|
||||||
if (!caseSensitive)
|
|
||||||
data = lowercase(data);
|
|
||||||
|
|
||||||
bool found = true;
|
|
||||||
|
|
||||||
// Loop over all search words...
|
|
||||||
if (caseSensitive) {
|
|
||||||
for (vector<string>::const_iterator sit=
|
|
||||||
searchwords.begin();
|
|
||||||
sit<searchwords.end(); ++sit) {
|
|
||||||
if (data.find(*sit) == string::npos) {
|
|
||||||
found = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (vector<string>::const_iterator sit=
|
|
||||||
searchwords.begin();
|
|
||||||
sit<searchwords.end(); ++sit) {
|
|
||||||
if (data.find(lowercase(*sit)) ==
|
|
||||||
string::npos) {
|
|
||||||
found = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::const_iterator
|
|
||||||
regexSearch(ControlCitation const & controller,
|
|
||||||
vector<string> const & keys,
|
|
||||||
string const & expr,
|
|
||||||
vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Direction dir)
|
|
||||||
{
|
|
||||||
LRegex reg(expr);
|
|
||||||
|
|
||||||
for (vector<string>::const_iterator it = start;
|
|
||||||
// End condition is direction-dependent.
|
|
||||||
(dir == ControlCitation::FORWARD) ?
|
|
||||||
(it<keys.end()) : (it>=keys.begin());
|
|
||||||
// increment is direction-dependent.
|
|
||||||
(dir == ControlCitation::FORWARD) ?
|
|
||||||
(++it) : (--it)) {
|
|
||||||
|
|
||||||
string data = (*it);
|
|
||||||
ControlCitation::InfoMap::const_iterator info =
|
|
||||||
controller.bibkeysInfo().find(*it);
|
|
||||||
if (info != controller.bibkeysInfo().end())
|
|
||||||
data += " " + info->second;
|
|
||||||
|
|
||||||
if (reg.exec(data).size() > 0)
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
string const parseBibTeX(string data, string const & findkey)
|
|
||||||
{
|
|
||||||
string keyvalue;
|
|
||||||
|
|
||||||
for (string::iterator it=data.begin(); it<data.end(); ++it) {
|
|
||||||
if ((*it) == '\n' || (*it) == '\t')
|
|
||||||
(*it)= ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
data = frontStrip(data);
|
|
||||||
while (!data.empty() && data[0] != '=' &&
|
|
||||||
(data.find(' ') != string::npos || data.find('=') != string::npos)) {
|
|
||||||
|
|
||||||
string::size_type keypos = min(data.find(' '), data.find('='));
|
|
||||||
string key = lowercase(data.substr(0, keypos));
|
|
||||||
|
|
||||||
data = data.substr(keypos, data.length()-1);
|
|
||||||
data = frontStrip(strip(data));
|
|
||||||
if (data.length() > 1 && data[0]=='=') {
|
|
||||||
data = frontStrip(data.substr(1, data.length()-1));
|
|
||||||
if (!data.empty()) {
|
|
||||||
keypos = 1;
|
|
||||||
string value;
|
|
||||||
char enclosing;
|
|
||||||
|
|
||||||
if (data[0]=='{') {
|
|
||||||
enclosing = '}';
|
|
||||||
} else if (data[0]=='"') {
|
|
||||||
enclosing = '"';
|
|
||||||
} else {
|
|
||||||
keypos=0;
|
|
||||||
enclosing=' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keypos &&
|
|
||||||
data.find(enclosing)!=string::npos &&
|
|
||||||
data.length()>1) {
|
|
||||||
string tmp = data.substr(keypos,
|
|
||||||
data.length()-1);
|
|
||||||
while (tmp.find('{') != string::npos &&
|
|
||||||
tmp.find('}') != string::npos &&
|
|
||||||
tmp.find('{') < tmp.find('}') &&
|
|
||||||
tmp.find('{') < tmp.find(enclosing)) {
|
|
||||||
|
|
||||||
keypos += tmp.find('{')+1;
|
|
||||||
tmp = data.substr(keypos,
|
|
||||||
data.length()-1);
|
|
||||||
keypos += tmp.find('}')+1;
|
|
||||||
tmp = data.substr(keypos,
|
|
||||||
data.length()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmp.find(enclosing)==string::npos)
|
|
||||||
return keyvalue;
|
|
||||||
else {
|
|
||||||
keypos += tmp.find(enclosing);
|
|
||||||
tmp = data.substr(keypos,
|
|
||||||
data.length()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
value = data.substr(1, keypos-1);
|
|
||||||
|
|
||||||
if (keypos+1<data.length()-1)
|
|
||||||
data = frontStrip(data.substr(keypos+1, data.length()-1));
|
|
||||||
else
|
|
||||||
data = "";
|
|
||||||
|
|
||||||
} else if (!keypos &&
|
|
||||||
(data.find(' ') ||
|
|
||||||
data.find(','))) {
|
|
||||||
keypos = data.length()-1;
|
|
||||||
if (data.find(' ') != string::npos)
|
|
||||||
keypos = data.find(' ');
|
|
||||||
if (data.find(',') != string::npos &&
|
|
||||||
keypos > data.find(','))
|
|
||||||
keypos = data.find(',');
|
|
||||||
|
|
||||||
value = data.substr(0, keypos);
|
|
||||||
|
|
||||||
if (keypos+1<data.length()-1)
|
|
||||||
data = frontStrip(data.substr(keypos+1, data.length()-1));
|
|
||||||
else
|
|
||||||
data = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return keyvalue;
|
|
||||||
|
|
||||||
if (findkey == key) {
|
|
||||||
keyvalue = value;
|
|
||||||
return keyvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = frontStrip(frontStrip(data,','));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else return keyvalue;
|
|
||||||
}
|
|
||||||
return keyvalue;
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/* This file is part of
|
/* This file is part of
|
||||||
* ======================================================
|
* ======================================================
|
||||||
*
|
*
|
||||||
@ -20,6 +19,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ControlCommand.h"
|
#include "ControlCommand.h"
|
||||||
|
#include "biblio.h" // biblio::InfoMap
|
||||||
|
|
||||||
/** A controller for Citation dialogs. All citation-specific functionality
|
/** A controller for Citation dialogs. All citation-specific functionality
|
||||||
should go in here.
|
should go in here.
|
||||||
@ -27,85 +27,20 @@
|
|||||||
class ControlCitation : public ControlCommand
|
class ControlCitation : public ControlCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
|
||||||
typedef std::map<string, string> InfoMap;
|
|
||||||
///
|
|
||||||
typedef std::map<string, string>::value_type InfoMapValue;
|
|
||||||
///
|
|
||||||
enum Search {
|
|
||||||
///
|
|
||||||
SIMPLE,
|
|
||||||
///
|
|
||||||
REGEX
|
|
||||||
};
|
|
||||||
///
|
|
||||||
enum Direction {
|
|
||||||
///
|
|
||||||
FORWARD,
|
|
||||||
///
|
|
||||||
BACKWARD
|
|
||||||
};
|
|
||||||
///
|
///
|
||||||
ControlCitation(LyXView &, Dialogs &);
|
ControlCitation(LyXView &, Dialogs &);
|
||||||
/// A vector of bibliography keys
|
|
||||||
std::vector<string> const getBibkeys();
|
|
||||||
/// Returns a reference to the map of stored keys
|
/// Returns a reference to the map of stored keys
|
||||||
InfoMap const & bibkeysInfo() const { return bibkeysInfo_; }
|
biblio::InfoMap const & bibkeysInfo() const;
|
||||||
/** Returns the BibTeX data associated with a given key.
|
|
||||||
Empty if no info exists. */
|
|
||||||
string const getBibkeyInfo(string const &);
|
|
||||||
private:
|
private:
|
||||||
/// clean-up any daughter class-particular data on hide().
|
/// create the InfoMap of keys and data
|
||||||
|
virtual void setDaughterParams();
|
||||||
|
///
|
||||||
virtual void clearDaughterParams();
|
virtual void clearDaughterParams();
|
||||||
|
|
||||||
/// The info associated with each key
|
/// The info associated with each key
|
||||||
InfoMap bibkeysInfo_;
|
biblio::InfoMap bibkeysInfo_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Helper functions, of possible use to all frontends
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Search a BibTeX info field for the given key and return the
|
|
||||||
associated field. */
|
|
||||||
string const parseBibTeX(string data, string const & findkey);
|
|
||||||
|
|
||||||
/** Returns an iterator to the first key that meets the search criterion,
|
|
||||||
or end() if unsuccessful.
|
|
||||||
|
|
||||||
User supplies :
|
|
||||||
the controller with the map of bibkeys info,
|
|
||||||
the vector of keys to be searched,
|
|
||||||
the search criterion,
|
|
||||||
an iterator defining the starting point of the search,
|
|
||||||
an enum defining a Simple or Regex search,
|
|
||||||
an enum defining the search direction.
|
|
||||||
*/
|
|
||||||
|
|
||||||
std::vector<string>::const_iterator
|
|
||||||
searchKeys(ControlCitation const & controller,
|
|
||||||
std::vector<string> const & keys_to_search,
|
|
||||||
string const & search_expression,
|
|
||||||
std::vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Search,
|
|
||||||
ControlCitation::Direction,
|
|
||||||
bool caseSensitive=false);
|
|
||||||
|
|
||||||
/// Do the dirty work for the search. Should use through the function above
|
|
||||||
std::vector<string>::const_iterator
|
|
||||||
simpleSearch(ControlCitation const & controller,
|
|
||||||
std::vector<string> const & keys_to_search,
|
|
||||||
string const & search_expression,
|
|
||||||
std::vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Direction,
|
|
||||||
bool caseSensitive=false);
|
|
||||||
|
|
||||||
/// Should use through the function above
|
|
||||||
std::vector<string>::const_iterator
|
|
||||||
regexSearch(ControlCitation const & controller,
|
|
||||||
std::vector<string> const & keys_to_search,
|
|
||||||
string const & search_expression,
|
|
||||||
std::vector<string>::const_iterator start,
|
|
||||||
ControlCitation::Direction);
|
|
||||||
#endif // CONTROLCITATION_H
|
#endif // CONTROLCITATION_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ private:
|
|||||||
virtual void applyParamsToInset() {}
|
virtual void applyParamsToInset() {}
|
||||||
///
|
///
|
||||||
virtual void applyParamsNoInset() {}
|
virtual void applyParamsNoInset() {}
|
||||||
///
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
/// get the parameters from the string passed to createInset.
|
/// get the parameters from the string passed to createInset.
|
||||||
virtual string const getParams(string const &) { return string(); }
|
virtual string const getParams(string const &) { return string(); }
|
||||||
/// get the parameters from the inset passed to showInset.
|
/// get the parameters from the inset passed to showInset.
|
||||||
|
66
src/frontends/controllers/ControlGraphics.C
Normal file
66
src/frontends/controllers/ControlGraphics.C
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlGraphics.C
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlGraphics.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "Dialogs.h"
|
||||||
|
#include "lyxfunc.h"
|
||||||
|
#include "LyXView.h"
|
||||||
|
|
||||||
|
#include "insets/insetgraphics.h"
|
||||||
|
|
||||||
|
ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
|
||||||
|
: ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
|
||||||
|
{
|
||||||
|
d_.showGraphics.connect(SigC::slot(this, &ControlGraphics::showInset));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LyXView * ControlGraphics::lv() const
|
||||||
|
{
|
||||||
|
return &lv_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InsetGraphicsParams const ControlGraphics::getParams(string const &)
|
||||||
|
{
|
||||||
|
return InsetGraphicsParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InsetGraphicsParams const
|
||||||
|
ControlGraphics::getParams(InsetGraphics const & inset)
|
||||||
|
{
|
||||||
|
return inset.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlGraphics::applyParamsToInset()
|
||||||
|
{
|
||||||
|
// Set the parameters in the inset, it also returns true if the new
|
||||||
|
// parameters are different from what was in the inset already.
|
||||||
|
bool changed = inset()->setParams(params());
|
||||||
|
// Tell LyX we've got a change, and mark the document dirty,
|
||||||
|
// if it changed.
|
||||||
|
lv_.view()->updateInset(inset(), changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlGraphics::applyParamsNoInset()
|
||||||
|
{}
|
49
src/frontends/controllers/ControlGraphics.h
Normal file
49
src/frontends/controllers/ControlGraphics.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlGraphics.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTROLGRAPHICS_H
|
||||||
|
#define CONTROLGRAPHICS_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlInset.h"
|
||||||
|
#include "insets/insetgraphicsParams.h" // need operator!=()
|
||||||
|
|
||||||
|
class InsetGraphics;
|
||||||
|
class LyXView;
|
||||||
|
|
||||||
|
/** A controller for Graphics dialogs.
|
||||||
|
*/
|
||||||
|
class ControlGraphics
|
||||||
|
: public ControlInset<InsetGraphics, InsetGraphicsParams> {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
ControlGraphics(LyXView &, Dialogs &);
|
||||||
|
|
||||||
|
/// The file dialog popup requires a LyXView * ???
|
||||||
|
LyXView * lv() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Dispatch the changed parameters to the kernel.
|
||||||
|
virtual void applyParamsToInset();
|
||||||
|
///
|
||||||
|
virtual void applyParamsNoInset();
|
||||||
|
/// get the parameters from the string passed to createInset.
|
||||||
|
virtual InsetGraphicsParams const getParams(string const &);
|
||||||
|
/// get the parameters from the inset passed to showInset.
|
||||||
|
virtual InsetGraphicsParams const getParams(InsetGraphics const &);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONTROLGRAPHICS_H
|
@ -35,8 +35,6 @@ private:
|
|||||||
virtual void applyParamsToInset();
|
virtual void applyParamsToInset();
|
||||||
/// Should be used but currently isn't
|
/// Should be used but currently isn't
|
||||||
virtual void applyParamsNoInset() {}
|
virtual void applyParamsNoInset() {}
|
||||||
/// not needed.
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
/// get the parameters from the string passed to createInset.
|
/// get the parameters from the string passed to createInset.
|
||||||
virtual InsetInclude::Params const getParams(string const &)
|
virtual InsetInclude::Params const getParams(string const &)
|
||||||
{ return InsetInclude::Params(); }
|
{ return InsetInclude::Params(); }
|
||||||
|
32
src/frontends/controllers/ControlIndex.C
Normal file
32
src/frontends/controllers/ControlIndex.C
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlIndex.C
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlIndex.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "Dialogs.h"
|
||||||
|
#include "LyXView.h"
|
||||||
|
|
||||||
|
using SigC::slot;
|
||||||
|
|
||||||
|
ControlIndex::ControlIndex(LyXView & lv, Dialogs & d)
|
||||||
|
: ControlCommand(lv, d, LFUN_INDEX_INSERT)
|
||||||
|
{
|
||||||
|
d_.showIndex.connect(slot(this, &ControlIndex::showInset));
|
||||||
|
d_.createIndex.connect(slot(this, &ControlIndex::createInset));
|
||||||
|
}
|
31
src/frontends/controllers/ControlIndex.h
Normal file
31
src/frontends/controllers/ControlIndex.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file ControlIndex.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTROLINDEX_H
|
||||||
|
#define CONTROLINDEX_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ControlCommand.h"
|
||||||
|
|
||||||
|
/** A controller for Index dialogs.
|
||||||
|
*/
|
||||||
|
class ControlIndex : public ControlCommand {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
ControlIndex(LyXView &, Dialogs &);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONTROLINDEX_H
|
@ -36,24 +36,34 @@ protected:
|
|||||||
/// Slot launching dialog to (possibly) create a new inset.
|
/// Slot launching dialog to (possibly) create a new inset.
|
||||||
void createInset(string const &);
|
void createInset(string const &);
|
||||||
/// Slot launching dialog to an existing inset.
|
/// Slot launching dialog to an existing inset.
|
||||||
void showInset(Inset * inset);
|
void showInset(Inset *);
|
||||||
/// Allow the daughter methods to access the inset.
|
/// Allow the daughter methods to access the inset.
|
||||||
Inset * inset() const;
|
Inset * inset() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** These methods are all that the individual daughter classes
|
/** These 6 methods are all that the individual daughter classes
|
||||||
should need to instantiate. */
|
should need to instantiate. */
|
||||||
|
|
||||||
/// if the inset exists then do this...
|
/// if the inset exists then do this...
|
||||||
virtual void applyParamsToInset() = 0;
|
virtual void applyParamsToInset() = 0;
|
||||||
/// else this...
|
/// else this...
|
||||||
virtual void applyParamsNoInset() = 0;
|
virtual void applyParamsNoInset() = 0;
|
||||||
|
|
||||||
/// get the parameters from the string passed to createInset.
|
/// get the parameters from the string passed to createInset.
|
||||||
virtual Params const getParams(string const &) = 0;
|
virtual Params const getParams(string const &) = 0;
|
||||||
/// get the parameters from the inset passed to showInset.
|
/// get the parameters from the inset passed to showInset.
|
||||||
virtual Params const getParams(Inset const &) = 0;
|
virtual Params const getParams(Inset const &) = 0;
|
||||||
|
|
||||||
|
/** Most derived classes won't need these two, so they default to empty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// set any daughter class-particular data on show().
|
||||||
|
virtual void setDaughterParams() {}
|
||||||
/// clean-up any daughter class-particular data on hide().
|
/// clean-up any daughter class-particular data on hide().
|
||||||
virtual void clearDaughterParams() = 0;
|
virtual void clearDaughterParams() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Instantiation of ControlBase virtual methods.
|
/// Instantiation of ControlBase virtual methods.
|
||||||
|
|
||||||
@ -124,6 +134,8 @@ void ControlInset<Inset, Params>::show(Params const & params)
|
|||||||
if (params_) delete params_;
|
if (params_) delete params_;
|
||||||
params_ = new Params(params);
|
params_ = new Params(params);
|
||||||
|
|
||||||
|
setDaughterParams();
|
||||||
|
|
||||||
bc().readOnly(isReadonly());
|
bc().readOnly(isReadonly());
|
||||||
view().show();
|
view().show();
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,17 @@
|
|||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
using SigC::slot;
|
using SigC::slot;
|
||||||
|
|
||||||
ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
|
ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
|
||||||
: ControlInset<InsetMinipage, MinipageParams>(lv, d)
|
: ControlInset<InsetMinipage, MinipageParams>(lv, d)
|
||||||
{
|
{
|
||||||
d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
|
d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
|
||||||
|
|
||||||
|
// We could have an extra method updateInset that calls
|
||||||
|
// view().update() rather than view().show(), but I don't see why
|
||||||
|
// it is really needed.
|
||||||
d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
|
d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +42,8 @@ void ControlMinipage::applyParamsToInset()
|
|||||||
inset()->width(params().width);
|
inset()->width(params().width);
|
||||||
inset()->widthp(params().widthp);
|
inset()->widthp(params().widthp);
|
||||||
inset()->pos(params().pos);
|
inset()->pos(params().pos);
|
||||||
|
|
||||||
|
lv_.view()->updateInset(inset(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,3 +75,22 @@ bool MinipageParams::operator!=(MinipageParams const & o) const
|
|||||||
{
|
{
|
||||||
return !(*this == o);
|
return !(*this == o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace minipage {
|
||||||
|
|
||||||
|
vector<string> const getUnits()
|
||||||
|
{
|
||||||
|
vector<string> units;
|
||||||
|
units.push_back("mm");
|
||||||
|
units.push_back("in");
|
||||||
|
units.push_back("em");
|
||||||
|
units.push_back("\%");
|
||||||
|
units.push_back("\%c");
|
||||||
|
units.push_back("\%l");
|
||||||
|
units.push_back("\%p");
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace minipage
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#ifndef CONTROLMINIPAGE_H
|
#ifndef CONTROLMINIPAGE_H
|
||||||
#define CONTROLMINIPAGE_H
|
#define CONTROLMINIPAGE_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
@ -59,8 +61,6 @@ private:
|
|||||||
virtual void applyParamsToInset();
|
virtual void applyParamsToInset();
|
||||||
///
|
///
|
||||||
virtual void applyParamsNoInset();
|
virtual void applyParamsNoInset();
|
||||||
///
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
/// get the parameters from the string passed to createInset.
|
/// get the parameters from the string passed to createInset.
|
||||||
virtual MinipageParams const getParams(string const &)
|
virtual MinipageParams const getParams(string const &)
|
||||||
{ return MinipageParams(); }
|
{ return MinipageParams(); }
|
||||||
@ -68,4 +68,11 @@ private:
|
|||||||
virtual MinipageParams const getParams(InsetMinipage const &);
|
virtual MinipageParams const getParams(InsetMinipage const &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Helper functions
|
||||||
|
namespace minipage {
|
||||||
|
|
||||||
|
std::vector<string> const getUnits();
|
||||||
|
|
||||||
|
} // namespace minipage
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,10 +33,6 @@ public:
|
|||||||
void gotoRef(string const &) const;
|
void gotoRef(string const &) const;
|
||||||
///
|
///
|
||||||
void gotoBookmark() const;
|
void gotoBookmark() const;
|
||||||
|
|
||||||
private:
|
|
||||||
/// not needed.
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLREF_H
|
#endif // CONTROLREF_H
|
||||||
|
@ -38,8 +38,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
/// not needed.
|
/// not needed.
|
||||||
virtual void apply() {}
|
virtual void apply() {}
|
||||||
///
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLSEARCH_H
|
#endif // CONTROLSEARCH_H
|
||||||
|
@ -27,10 +27,6 @@ class ControlUrl : public ControlCommand
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
ControlUrl(LyXView &, Dialogs &);
|
ControlUrl(LyXView &, Dialogs &);
|
||||||
|
|
||||||
private:
|
|
||||||
/// not needed.
|
|
||||||
virtual void clearDaughterParams() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLURL_H
|
#endif // CONTROLURL_H
|
||||||
|
@ -140,6 +140,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Specialization for Graphics dialog
|
||||||
|
*/
|
||||||
|
class ControlGraphics;
|
||||||
|
|
||||||
|
template <class GUIview, class GUIbc>
|
||||||
|
class GUIGraphics :
|
||||||
|
public GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
GUIGraphics(LyXView & lv, Dialogs & d)
|
||||||
|
: GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Specialization for Include dialog
|
/** Specialization for Include dialog
|
||||||
*/
|
*/
|
||||||
class ControlInclude;
|
class ControlInclude;
|
||||||
@ -154,6 +168,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Specialization for Index dialog
|
||||||
|
*/
|
||||||
|
class ControlIndex;
|
||||||
|
|
||||||
|
template <class GUIview, class GUIbc>
|
||||||
|
class GUIIndex :
|
||||||
|
public GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
GUIIndex(LyXView & lv, Dialogs & d)
|
||||||
|
: GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Specialization for Log dialog
|
/** Specialization for Log dialog
|
||||||
*/
|
*/
|
||||||
class ControlLog;
|
class ControlLog;
|
||||||
@ -174,11 +202,11 @@ class ControlMinipage;
|
|||||||
|
|
||||||
template <class GUIview, class GUIbc>
|
template <class GUIview, class GUIbc>
|
||||||
class GUIMinipage :
|
class GUIMinipage :
|
||||||
public GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc> {
|
public GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
GUIMinipage(LyXView & lv, Dialogs & d)
|
GUIMinipage(LyXView & lv, Dialogs & d)
|
||||||
: GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
|
: GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ LIBS =
|
|||||||
SUBDIRS =
|
SUBDIRS =
|
||||||
ETAGS_ARGS = --lang=c++
|
ETAGS_ARGS = --lang=c++
|
||||||
libcontrollers_la_SOURCES=\
|
libcontrollers_la_SOURCES=\
|
||||||
|
biblio.C \
|
||||||
|
biblio.h \
|
||||||
|
character.C \
|
||||||
|
character.h \
|
||||||
ButtonController.C \
|
ButtonController.C \
|
||||||
ButtonController.h \
|
ButtonController.h \
|
||||||
ButtonPolicies.C \
|
ButtonPolicies.C \
|
||||||
@ -35,8 +39,12 @@ libcontrollers_la_SOURCES=\
|
|||||||
ControlDialogs.h \
|
ControlDialogs.h \
|
||||||
ControlError.h \
|
ControlError.h \
|
||||||
ControlError.C \
|
ControlError.C \
|
||||||
|
ControlGraphics.h \
|
||||||
|
ControlGraphics.C \
|
||||||
ControlInclude.C \
|
ControlInclude.C \
|
||||||
ControlInclude.h \
|
ControlInclude.h \
|
||||||
|
ControlIndex.C \
|
||||||
|
ControlIndex.h \
|
||||||
ControlInset.h \
|
ControlInset.h \
|
||||||
ControlLog.C \
|
ControlLog.C \
|
||||||
ControlLog.h \
|
ControlLog.h \
|
||||||
|
327
src/frontends/controllers/biblio.C
Normal file
327
src/frontends/controllers/biblio.C
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file biblio.C
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "Dialogs.h"
|
||||||
|
#include "LyXView.h"
|
||||||
|
*/
|
||||||
|
#include "LString.h"
|
||||||
|
#include "biblio.h"
|
||||||
|
#include "helper_funcs.h"
|
||||||
|
#include "support/lstrings.h"
|
||||||
|
#include "support/LAssert.h"
|
||||||
|
#include "support/LRegex.h"
|
||||||
|
|
||||||
|
using std::find;
|
||||||
|
using std::min;
|
||||||
|
using std::pair;
|
||||||
|
using std::vector;
|
||||||
|
using std::sort;
|
||||||
|
|
||||||
|
namespace biblio
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// A functor for use with std::sort, leading to case insensitive sorting
|
||||||
|
struct compareNoCase: public std::binary_function<string, string, bool>
|
||||||
|
{
|
||||||
|
bool operator()(string const & s1, string const & s2) const {
|
||||||
|
return compare_no_case(s1, s2) < 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
vector<string> const getKeys(InfoMap const & map)
|
||||||
|
{
|
||||||
|
vector<string> bibkeys;
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::map<string, string>::value_type InfoMapValue;
|
||||||
|
|
||||||
|
for (InfoMap::const_iterator it = map.begin(); it != map.end(); ++it) {
|
||||||
|
bibkeys.push_back(it->first);
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(bibkeys.begin(), bibkeys.end(), compareNoCase());
|
||||||
|
return bibkeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const getInfo(InfoMap const & map, string const & key)
|
||||||
|
{
|
||||||
|
Assert(!map.empty());
|
||||||
|
|
||||||
|
string result;
|
||||||
|
|
||||||
|
InfoMap::const_iterator it = map.find(key);
|
||||||
|
if (it != map.end()) {
|
||||||
|
// Search for all possible "required" keys
|
||||||
|
string author = parseBibTeX(it->second, "author");
|
||||||
|
if (author.empty())
|
||||||
|
author = parseBibTeX(it->second, "editor");
|
||||||
|
|
||||||
|
string year = parseBibTeX(it->second, "year");
|
||||||
|
string title = parseBibTeX(it->second, "title");
|
||||||
|
string booktitle = parseBibTeX(it->second, "booktitle");
|
||||||
|
string chapter = parseBibTeX(it->second, "chapter");
|
||||||
|
string pages = parseBibTeX(it->second, "pages");
|
||||||
|
|
||||||
|
string media = parseBibTeX(it->second, "journal");
|
||||||
|
if (media.empty())
|
||||||
|
media = parseBibTeX(it->second, "publisher");
|
||||||
|
if (media.empty())
|
||||||
|
media = parseBibTeX(it->second, "school");
|
||||||
|
if (media.empty())
|
||||||
|
media = parseBibTeX(it->second, "institution");
|
||||||
|
|
||||||
|
result = author;
|
||||||
|
if (!year.empty())
|
||||||
|
result += ", " + year;
|
||||||
|
if (!title.empty())
|
||||||
|
result += ", " + title;
|
||||||
|
if (!booktitle.empty())
|
||||||
|
result += ", in " + booktitle;
|
||||||
|
if (!chapter.empty())
|
||||||
|
result += ", Ch. " + chapter;
|
||||||
|
if (!media.empty())
|
||||||
|
result += ", " + media;
|
||||||
|
if (!pages.empty())
|
||||||
|
result += ", pp. " + pages;
|
||||||
|
|
||||||
|
if (result.empty()) // not a BibTeX record
|
||||||
|
result = it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<string>::const_iterator
|
||||||
|
searchKeys(InfoMap const & theMap,
|
||||||
|
vector<string> const & keys,
|
||||||
|
string const & expr,
|
||||||
|
vector<string>::const_iterator start,
|
||||||
|
Search type,
|
||||||
|
Direction dir,
|
||||||
|
bool caseSensitive)
|
||||||
|
{
|
||||||
|
// Preliminary checks
|
||||||
|
if(start < keys.begin() || start >= keys.end())
|
||||||
|
return keys.end();
|
||||||
|
|
||||||
|
string search_expr = frontStrip(strip(expr));
|
||||||
|
if (search_expr.empty())
|
||||||
|
return start;
|
||||||
|
|
||||||
|
if (type == SIMPLE)
|
||||||
|
return simpleSearch(theMap, keys, search_expr, start, dir,
|
||||||
|
caseSensitive);
|
||||||
|
|
||||||
|
return regexSearch(theMap, keys, search_expr, start, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<string>::const_iterator
|
||||||
|
simpleSearch(InfoMap const & theMap,
|
||||||
|
vector<string> const & keys,
|
||||||
|
string const & expr,
|
||||||
|
vector<string>::const_iterator start,
|
||||||
|
Direction dir,
|
||||||
|
bool caseSensitive)
|
||||||
|
{
|
||||||
|
vector<string> searchwords = getVectorFromString(expr, " ");
|
||||||
|
|
||||||
|
// Loop over all keys from start...
|
||||||
|
for (vector<string>::const_iterator it = start;
|
||||||
|
// End condition is direction-dependent.
|
||||||
|
(dir == FORWARD) ? (it<keys.end()) : (it>=keys.begin());
|
||||||
|
// increment is direction-dependent.
|
||||||
|
(dir == FORWARD) ? (++it) : (--it)) {
|
||||||
|
|
||||||
|
string data = (*it);
|
||||||
|
biblio::InfoMap::const_iterator info = theMap.find(*it);
|
||||||
|
if (info != theMap.end())
|
||||||
|
data += " " + info->second;
|
||||||
|
if (!caseSensitive)
|
||||||
|
data = lowercase(data);
|
||||||
|
|
||||||
|
bool found = true;
|
||||||
|
|
||||||
|
// Loop over all search words...
|
||||||
|
if (caseSensitive) {
|
||||||
|
for (vector<string>::const_iterator sit=
|
||||||
|
searchwords.begin();
|
||||||
|
sit<searchwords.end(); ++sit) {
|
||||||
|
if (data.find(*sit) == string::npos) {
|
||||||
|
found = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (vector<string>::const_iterator sit=
|
||||||
|
searchwords.begin();
|
||||||
|
sit<searchwords.end(); ++sit) {
|
||||||
|
if (data.find(lowercase(*sit)) ==
|
||||||
|
string::npos) {
|
||||||
|
found = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<string>::const_iterator
|
||||||
|
regexSearch(InfoMap const & theMap,
|
||||||
|
vector<string> const & keys,
|
||||||
|
string const & expr,
|
||||||
|
vector<string>::const_iterator start,
|
||||||
|
Direction dir)
|
||||||
|
{
|
||||||
|
LRegex reg(expr);
|
||||||
|
|
||||||
|
for (vector<string>::const_iterator it = start;
|
||||||
|
// End condition is direction-dependent.
|
||||||
|
(dir == FORWARD) ? (it<keys.end()) : (it>=keys.begin());
|
||||||
|
// increment is direction-dependent.
|
||||||
|
(dir == FORWARD) ? (++it) : (--it)) {
|
||||||
|
|
||||||
|
string data = (*it);
|
||||||
|
biblio::InfoMap::const_iterator info = theMap.find(*it);
|
||||||
|
if (info != theMap.end())
|
||||||
|
data += " " + info->second;
|
||||||
|
|
||||||
|
if (reg.exec(data).size() > 0)
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
string const parseBibTeX(string data, string const & findkey)
|
||||||
|
{
|
||||||
|
string keyvalue;
|
||||||
|
|
||||||
|
for (string::iterator it=data.begin(); it<data.end(); ++it) {
|
||||||
|
if ((*it) == '\n' || (*it) == '\t')
|
||||||
|
(*it)= ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
data = frontStrip(data);
|
||||||
|
while (!data.empty() && data[0] != '=' &&
|
||||||
|
(data.find(' ') != string::npos || data.find('=') != string::npos)) {
|
||||||
|
|
||||||
|
string::size_type keypos = min(data.find(' '), data.find('='));
|
||||||
|
string key = lowercase(data.substr(0, keypos));
|
||||||
|
|
||||||
|
data = data.substr(keypos, data.length()-1);
|
||||||
|
data = frontStrip(strip(data));
|
||||||
|
if (data.length() > 1 && data[0]=='=') {
|
||||||
|
data = frontStrip(data.substr(1, data.length()-1));
|
||||||
|
if (!data.empty()) {
|
||||||
|
keypos = 1;
|
||||||
|
string value;
|
||||||
|
char enclosing;
|
||||||
|
|
||||||
|
if (data[0]=='{') {
|
||||||
|
enclosing = '}';
|
||||||
|
} else if (data[0]=='"') {
|
||||||
|
enclosing = '"';
|
||||||
|
} else {
|
||||||
|
keypos=0;
|
||||||
|
enclosing=' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keypos &&
|
||||||
|
data.find(enclosing)!=string::npos &&
|
||||||
|
data.length()>1) {
|
||||||
|
string tmp = data.substr(keypos,
|
||||||
|
data.length()-1);
|
||||||
|
while (tmp.find('{') != string::npos &&
|
||||||
|
tmp.find('}') != string::npos &&
|
||||||
|
tmp.find('{') < tmp.find('}') &&
|
||||||
|
tmp.find('{') < tmp.find(enclosing)) {
|
||||||
|
|
||||||
|
keypos += tmp.find('{')+1;
|
||||||
|
tmp = data.substr(keypos,
|
||||||
|
data.length()-1);
|
||||||
|
keypos += tmp.find('}')+1;
|
||||||
|
tmp = data.substr(keypos,
|
||||||
|
data.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp.find(enclosing)==string::npos)
|
||||||
|
return keyvalue;
|
||||||
|
else {
|
||||||
|
keypos += tmp.find(enclosing);
|
||||||
|
tmp = data.substr(keypos,
|
||||||
|
data.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = data.substr(1, keypos-1);
|
||||||
|
|
||||||
|
if (keypos+1<data.length()-1)
|
||||||
|
data = frontStrip(data.substr(keypos+1, data.length()-1));
|
||||||
|
else
|
||||||
|
data = "";
|
||||||
|
|
||||||
|
} else if (!keypos &&
|
||||||
|
(data.find(' ') ||
|
||||||
|
data.find(','))) {
|
||||||
|
keypos = data.length()-1;
|
||||||
|
if (data.find(' ') != string::npos)
|
||||||
|
keypos = data.find(' ');
|
||||||
|
if (data.find(',') != string::npos &&
|
||||||
|
keypos > data.find(','))
|
||||||
|
keypos = data.find(',');
|
||||||
|
|
||||||
|
value = data.substr(0, keypos);
|
||||||
|
|
||||||
|
if (keypos+1<data.length()-1)
|
||||||
|
data = frontStrip(data.substr(keypos+1, data.length()-1));
|
||||||
|
else
|
||||||
|
data = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return keyvalue;
|
||||||
|
|
||||||
|
if (findkey == key) {
|
||||||
|
keyvalue = value;
|
||||||
|
return keyvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = frontStrip(frontStrip(data,','));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return keyvalue;
|
||||||
|
}
|
||||||
|
return keyvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace biblio
|
||||||
|
|
96
src/frontends/controllers/biblio.h
Normal file
96
src/frontends/controllers/biblio.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file biblio.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BIBLIOHELPERS_H
|
||||||
|
#define BIBLIOHELPERS_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Functions of use to citation and bibtex GUI controllers and views */
|
||||||
|
namespace biblio
|
||||||
|
{
|
||||||
|
///
|
||||||
|
enum Search {
|
||||||
|
///
|
||||||
|
SIMPLE,
|
||||||
|
///
|
||||||
|
REGEX
|
||||||
|
};
|
||||||
|
///
|
||||||
|
enum Direction {
|
||||||
|
///
|
||||||
|
FORWARD,
|
||||||
|
///
|
||||||
|
BACKWARD
|
||||||
|
};
|
||||||
|
|
||||||
|
/// First entry is the bibliography key, second the data
|
||||||
|
typedef std::map<string, string> InfoMap;
|
||||||
|
|
||||||
|
/// Returns a vector of bibliography keys
|
||||||
|
std::vector<string> const getKeys(InfoMap const &);
|
||||||
|
|
||||||
|
/** Returns the BibTeX data associated with a given key.
|
||||||
|
Empty if no info exists. */
|
||||||
|
string const getInfo(InfoMap const &, string const &);
|
||||||
|
|
||||||
|
/** Search a BibTeX info field for the given key and return the
|
||||||
|
associated field. */
|
||||||
|
string const parseBibTeX(string data, string const & findkey);
|
||||||
|
|
||||||
|
/** Returns an iterator to the first key that meets the search
|
||||||
|
criterion, or end() if unsuccessful.
|
||||||
|
|
||||||
|
User supplies :
|
||||||
|
the InfoMap of bibkeys info,
|
||||||
|
the vector of keys to be searched,
|
||||||
|
the search criterion,
|
||||||
|
an iterator defining the starting point of the search,
|
||||||
|
an enum defining a Simple or Regex search,
|
||||||
|
an enum defining the search direction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
std::vector<string>::const_iterator
|
||||||
|
searchKeys(InfoMap const & map,
|
||||||
|
std::vector<string> const & keys_to_search,
|
||||||
|
string const & search_expression,
|
||||||
|
std::vector<string>::const_iterator start,
|
||||||
|
Search,
|
||||||
|
Direction,
|
||||||
|
bool caseSensitive=false);
|
||||||
|
|
||||||
|
/** Do the dirty work for the search.
|
||||||
|
Should use through the function above */
|
||||||
|
std::vector<string>::const_iterator
|
||||||
|
simpleSearch(InfoMap const & map,
|
||||||
|
std::vector<string> const & keys_to_search,
|
||||||
|
string const & search_expression,
|
||||||
|
std::vector<string>::const_iterator start,
|
||||||
|
Direction,
|
||||||
|
bool caseSensitive=false);
|
||||||
|
|
||||||
|
/// Should use through the function above
|
||||||
|
std::vector<string>::const_iterator
|
||||||
|
regexSearch(InfoMap const & map,
|
||||||
|
std::vector<string> const & keys_to_search,
|
||||||
|
string const & search_expression,
|
||||||
|
std::vector<string>::const_iterator start,
|
||||||
|
Direction);
|
||||||
|
|
||||||
|
} // namespace biblio
|
||||||
|
|
||||||
|
#endif // BIBLIOHELPERS_H
|
195
src/frontends/controllers/character.C
Normal file
195
src/frontends/controllers/character.C
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file character.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "character.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
namespace character {
|
||||||
|
|
||||||
|
vector<FamilyPair> const getFamilyData()
|
||||||
|
{
|
||||||
|
vector<FamilyPair> family(5);
|
||||||
|
|
||||||
|
FamilyPair pr;
|
||||||
|
pr.first = _("No change"); pr.second = LyXFont::IGNORE_FAMILY;
|
||||||
|
family[0] = pr;
|
||||||
|
pr.first = _("Roman"); pr.second = LyXFont::ROMAN_FAMILY;
|
||||||
|
family[1] = pr;
|
||||||
|
pr.first = _("Sans Serif"); pr.second = LyXFont::SANS_FAMILY;
|
||||||
|
family[2] = pr;
|
||||||
|
pr.first = _("Typewriter"); pr.second = LyXFont::TYPEWRITER_FAMILY;
|
||||||
|
family[3] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_FAMILY;
|
||||||
|
family[4] = pr;
|
||||||
|
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<SeriesPair> const getSeriesData()
|
||||||
|
{
|
||||||
|
vector<SeriesPair> series(4);
|
||||||
|
|
||||||
|
SeriesPair pr;
|
||||||
|
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SERIES;
|
||||||
|
series[0] = pr;
|
||||||
|
pr.first = _("Medium"); pr.second = LyXFont::MEDIUM_SERIES;
|
||||||
|
series[1] = pr;
|
||||||
|
pr.first = _("Bold"); pr.second = LyXFont::BOLD_SERIES;
|
||||||
|
series[2] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SERIES;
|
||||||
|
series[3] = pr;
|
||||||
|
|
||||||
|
return series;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<ShapePair> const getShapeData()
|
||||||
|
{
|
||||||
|
vector<ShapePair> shape(6);
|
||||||
|
|
||||||
|
ShapePair pr;
|
||||||
|
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SHAPE;
|
||||||
|
shape[0] = pr;
|
||||||
|
pr.first = _("Upright"); pr.second = LyXFont::UP_SHAPE;
|
||||||
|
shape[1] = pr;
|
||||||
|
pr.first = _("Italic"); pr.second = LyXFont::ITALIC_SHAPE;
|
||||||
|
shape[2] = pr;
|
||||||
|
pr.first = _("Slanted"); pr.second = LyXFont::SLANTED_SHAPE;
|
||||||
|
shape[3] = pr;
|
||||||
|
pr.first = _("Small Caps"); pr.second = LyXFont::SMALLCAPS_SHAPE;
|
||||||
|
shape[4] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SHAPE;
|
||||||
|
shape[5] = pr;
|
||||||
|
|
||||||
|
return shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<SizePair> const getSizeData()
|
||||||
|
{
|
||||||
|
vector<SizePair> size(14);
|
||||||
|
|
||||||
|
SizePair pr;
|
||||||
|
pr.first = _("No change"); pr.second = LyXFont::IGNORE_SIZE;
|
||||||
|
size[0] = pr;
|
||||||
|
pr.first = _("Tiny"); pr.second = LyXFont::SIZE_TINY;
|
||||||
|
size[1] = pr;
|
||||||
|
pr.first = _("Smallest"); pr.second = LyXFont::SIZE_SCRIPT;
|
||||||
|
size[2] = pr;
|
||||||
|
pr.first = _("Smaller"); pr.second = LyXFont::SIZE_FOOTNOTE;
|
||||||
|
size[3] = pr;
|
||||||
|
pr.first = _("Small"); pr.second = LyXFont::SIZE_SMALL;
|
||||||
|
size[4] = pr;
|
||||||
|
pr.first = _("Normal"); pr.second = LyXFont::SIZE_NORMAL;
|
||||||
|
size[5] = pr;
|
||||||
|
pr.first = _("Large"); pr.second = LyXFont::SIZE_LARGE;
|
||||||
|
size[6] = pr;
|
||||||
|
pr.first = _("Larger"); pr.second = LyXFont::SIZE_LARGER;
|
||||||
|
size[7] = pr;
|
||||||
|
pr.first = _("Largest"); pr.second = LyXFont::SIZE_LARGEST;
|
||||||
|
size[8] = pr;
|
||||||
|
pr.first = _("Huge"); pr.second = LyXFont::SIZE_HUGE;
|
||||||
|
size[9] = pr;
|
||||||
|
pr.first = _("Huger"); pr.second = LyXFont::SIZE_HUGER;
|
||||||
|
size[10] = pr;
|
||||||
|
pr.first = _("Increase"); pr.second = LyXFont::INCREASE_SIZE;
|
||||||
|
size[11] = pr;
|
||||||
|
pr.first = _("Decrease"); pr.second = LyXFont::DECREASE_SIZE;
|
||||||
|
size[12] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = LyXFont::INHERIT_SIZE;
|
||||||
|
size[13] = pr;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<BarPair> const getBarData()
|
||||||
|
{
|
||||||
|
vector<BarPair> bar(6);
|
||||||
|
|
||||||
|
BarPair pr;
|
||||||
|
pr.first = _("No change"); pr.second = IGNORE;
|
||||||
|
bar[0] = pr;
|
||||||
|
pr.first = _("Emph"); pr.second = EMPH_TOGGLE;
|
||||||
|
bar[1] = pr;
|
||||||
|
pr.first = _("Underbar"); pr.second = UNDERBAR_TOGGLE;
|
||||||
|
bar[2] = pr;
|
||||||
|
pr.first = _("Noun"); pr.second = NOUN_TOGGLE;
|
||||||
|
bar[3] = pr;
|
||||||
|
pr.first = _("LaTeX mode"); pr.second = LATEX_TOGGLE;
|
||||||
|
bar[4] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = INHERIT;
|
||||||
|
bar[5] = pr;
|
||||||
|
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<ColorPair> const getColorData()
|
||||||
|
{
|
||||||
|
vector<ColorPair> color(11);
|
||||||
|
|
||||||
|
ColorPair pr;
|
||||||
|
pr.first = _("No change"); pr.second = LColor::ignore;
|
||||||
|
color[0] = pr;
|
||||||
|
pr.first = _("No color"); pr.second = LColor::none;
|
||||||
|
color[1] = pr;
|
||||||
|
pr.first = _("Black"); pr.second = LColor::black;
|
||||||
|
color[2] = pr;
|
||||||
|
pr.first = _("White"); pr.second = LColor::white;
|
||||||
|
color[3] = pr;
|
||||||
|
pr.first = _("Red"); pr.second = LColor::red;
|
||||||
|
color[4] = pr;
|
||||||
|
pr.first = _("Green"); pr.second = LColor::green;
|
||||||
|
color[5] = pr;
|
||||||
|
pr.first = _("Blue"); pr.second = LColor::blue;
|
||||||
|
color[6] = pr;
|
||||||
|
pr.first = _("Cyan"); pr.second = LColor::cyan;
|
||||||
|
color[7] = pr;
|
||||||
|
pr.first = _("Magenta"); pr.second = LColor::magenta;
|
||||||
|
color[8] = pr;
|
||||||
|
pr.first = _("Yellow"); pr.second = LColor::yellow;
|
||||||
|
color[9] = pr;
|
||||||
|
pr.first = _("Reset"); pr.second = LColor::inherit;
|
||||||
|
color[10] = pr;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<string> const getLanguageData()
|
||||||
|
{
|
||||||
|
vector<string> langs(languages.size() + 2);
|
||||||
|
|
||||||
|
langs[0] = _("No change");
|
||||||
|
langs[1] = _("Reset");
|
||||||
|
|
||||||
|
vector<string>::size_type i = 1;
|
||||||
|
for (Languages::const_iterator cit = languages.begin();
|
||||||
|
cit != languages.end(); ++cit) {
|
||||||
|
langs[++i] = cit->second.lang();
|
||||||
|
}
|
||||||
|
|
||||||
|
return langs;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace character
|
73
src/frontends/controllers/character.h
Normal file
73
src/frontends/controllers/character.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 2001 The LyX Team.
|
||||||
|
*
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* \file character.h
|
||||||
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHARACTERHELPERS_H
|
||||||
|
#define CHARACTERHELPERS_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lyxfont.h"
|
||||||
|
#include "LColor.h"
|
||||||
|
#include "character.h"
|
||||||
|
|
||||||
|
/** Functions of use to the character GUI controller and view */
|
||||||
|
namespace character {
|
||||||
|
///
|
||||||
|
enum FONT_STATE {
|
||||||
|
///
|
||||||
|
IGNORE,
|
||||||
|
///
|
||||||
|
EMPH_TOGGLE,
|
||||||
|
///
|
||||||
|
UNDERBAR_TOGGLE,
|
||||||
|
///
|
||||||
|
NOUN_TOGGLE,
|
||||||
|
///
|
||||||
|
LATEX_TOGGLE,
|
||||||
|
///
|
||||||
|
INHERIT
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
typedef std::pair<string, LyXFont::FONT_FAMILY> FamilyPair;
|
||||||
|
///
|
||||||
|
typedef std::pair<string, LyXFont::FONT_SERIES> SeriesPair;
|
||||||
|
///
|
||||||
|
typedef std::pair<string, LyXFont::FONT_SHAPE> ShapePair;
|
||||||
|
///
|
||||||
|
typedef std::pair<string, LyXFont::FONT_SIZE> SizePair;
|
||||||
|
///
|
||||||
|
typedef std::pair<string, FONT_STATE> BarPair;
|
||||||
|
///
|
||||||
|
typedef std::pair<string, LColor::color> ColorPair;
|
||||||
|
|
||||||
|
///
|
||||||
|
std::vector<FamilyPair> const getFamilyData();
|
||||||
|
///
|
||||||
|
std::vector<SeriesPair> const getSeriesData();
|
||||||
|
///
|
||||||
|
std::vector<ShapePair> const getShapeData();
|
||||||
|
///
|
||||||
|
std::vector<SizePair> const getSizeData();
|
||||||
|
///
|
||||||
|
std::vector<BarPair> const getBarData();
|
||||||
|
///
|
||||||
|
std::vector<ColorPair> const getColorData();
|
||||||
|
///
|
||||||
|
std::vector<string> const getLanguageData();
|
||||||
|
|
||||||
|
} // namespace character
|
||||||
|
|
||||||
|
#endif // CHARACTERHELPERS
|
Loading…
Reference in New Issue
Block a user