mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Use a typedef for vector<Format const *>, which is what gets used
for lists of exportable and importable formats.
(cherry picked from commit 014bc7805e
)
This commit is contained in:
parent
1cdbf23d69
commit
e9b14eed60
@ -354,9 +354,8 @@ public:
|
||||
VSpace defskip;
|
||||
PDFOptions pdfoptions;
|
||||
LayoutFileIndex baseClass_;
|
||||
/// Caching for exportableFormats, which seems to be slow.
|
||||
std::vector<Format const *> exportableFormatList;
|
||||
std::vector<Format const *> viewableFormatList;
|
||||
FormatList exportableFormatList;
|
||||
FormatList viewableFormatList;
|
||||
bool isViewCacheValid;
|
||||
bool isExportCacheValid;
|
||||
};
|
||||
@ -2413,9 +2412,9 @@ bool BufferParams::isExportable(string const & format) const
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> const & BufferParams::exportableFormats(bool only_viewable) const
|
||||
FormatList const & BufferParams::exportableFormats(bool only_viewable) const
|
||||
{
|
||||
vector<Format const *> & cached = only_viewable ?
|
||||
FormatList & cached = only_viewable ?
|
||||
pimpl_->viewableFormatList : pimpl_->exportableFormatList;
|
||||
bool & valid = only_viewable ?
|
||||
pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
|
||||
@ -2428,12 +2427,12 @@ vector<Format const *> const & BufferParams::exportableFormats(bool only_viewabl
|
||||
excludes.insert("latex");
|
||||
excludes.insert("pdflatex");
|
||||
}
|
||||
vector<Format const *> result =
|
||||
FormatList result =
|
||||
theConverters().getReachable(backs[0], only_viewable, true, excludes);
|
||||
for (vector<string>::const_iterator it = backs.begin() + 1;
|
||||
it != backs.end(); ++it) {
|
||||
vector<Format const *> r =
|
||||
theConverters().getReachable(*it, only_viewable, false, excludes);
|
||||
FormatList r = theConverters().getReachable(*it, only_viewable,
|
||||
false, excludes);
|
||||
result.insert(result.end(), r.begin(), r.end());
|
||||
}
|
||||
sort(result.begin(), result.end(), Format::formatSorter);
|
||||
@ -2445,10 +2444,9 @@ vector<Format const *> const & BufferParams::exportableFormats(bool only_viewabl
|
||||
|
||||
bool BufferParams::isExportableFormat(string const & format) const
|
||||
{
|
||||
typedef vector<Format const *> Formats;
|
||||
Formats const & formats = exportableFormats(true);
|
||||
Formats::const_iterator fit = formats.begin();
|
||||
Formats::const_iterator end = formats.end();
|
||||
FormatList const & formats = exportableFormats(true);
|
||||
FormatList::const_iterator fit = formats.begin();
|
||||
FormatList::const_iterator end = formats.end();
|
||||
for (; fit != end ; ++fit) {
|
||||
if ((*fit)->name() == format)
|
||||
return true;
|
||||
@ -2543,7 +2541,7 @@ string BufferParams::getDefaultOutputFormat() const
|
||||
return default_output_format;
|
||||
if (isDocBook()
|
||||
|| encoding().package() == Encoding::japanese) {
|
||||
vector<Format const *> const & formats = exportableFormats(true);
|
||||
FormatList const & formats = exportableFormats(true);
|
||||
if (formats.empty())
|
||||
return string();
|
||||
// return the first we find
|
||||
|
@ -554,7 +554,7 @@ private:
|
||||
* mathdots, stackrel, stmaryrd and undertilde.
|
||||
*/
|
||||
PackageMap use_packages;
|
||||
|
||||
|
||||
/** Use the Pimpl idiom to hide those member variables that would otherwise
|
||||
* drag in other header files.
|
||||
*/
|
||||
|
@ -715,14 +715,13 @@ void Converters::buildGraph()
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> const
|
||||
Converters::intToFormat(vector<int> const & input)
|
||||
FormatList const Converters::intToFormat(vector<int> const & input)
|
||||
{
|
||||
vector<Format const *> result(input.size());
|
||||
FormatList result(input.size());
|
||||
|
||||
vector<int>::const_iterator it = input.begin();
|
||||
vector<int>::const_iterator const end = input.end();
|
||||
vector<Format const *>::iterator rit = result.begin();
|
||||
FormatList::iterator rit = result.begin();
|
||||
for ( ; it != end; ++it, ++rit) {
|
||||
*rit = &formats.get(*it);
|
||||
}
|
||||
@ -730,8 +729,8 @@ Converters::intToFormat(vector<int> const & input)
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> const
|
||||
Converters::getReachableTo(string const & target, bool const clear_visited)
|
||||
FormatList const Converters::getReachableTo(string const & target,
|
||||
bool const clear_visited)
|
||||
{
|
||||
vector<int> const & reachablesto =
|
||||
G_.getReachableTo(formats.getNumber(target), clear_visited);
|
||||
@ -740,9 +739,9 @@ Converters::getReachableTo(string const & target, bool const clear_visited)
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> const
|
||||
Converters::getReachable(string const & from, bool const only_viewable,
|
||||
bool const clear_visited, set<string> const & excludes)
|
||||
FormatList const Converters::getReachable(string const & from,
|
||||
bool const only_viewable, bool const clear_visited,
|
||||
set<string> const & excludes)
|
||||
{
|
||||
set<int> excluded_numbers;
|
||||
|
||||
@ -775,29 +774,28 @@ Graph::EdgePath Converters::getPath(string const & from, string const & to)
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> Converters::importableFormats()
|
||||
FormatList Converters::importableFormats()
|
||||
{
|
||||
vector<string> l = loaders();
|
||||
vector<Format const *> result = getReachableTo(l[0], true);
|
||||
FormatList result = getReachableTo(l[0], true);
|
||||
vector<string>::const_iterator it = l.begin() + 1;
|
||||
vector<string>::const_iterator en = l.end();
|
||||
for (; it != en; ++it) {
|
||||
vector<Format const *> r = getReachableTo(*it, false);
|
||||
FormatList r = getReachableTo(*it, false);
|
||||
result.insert(result.end(), r.begin(), r.end());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
vector<Format const *> Converters::exportableFormats(bool only_viewable)
|
||||
FormatList Converters::exportableFormats(bool only_viewable)
|
||||
{
|
||||
vector<string> s = savers();
|
||||
vector<Format const *> result = getReachable(s[0], only_viewable, true);
|
||||
FormatList result = getReachable(s[0], only_viewable, true);
|
||||
vector<string>::const_iterator it = s.begin() + 1;
|
||||
vector<string>::const_iterator en = s.end();
|
||||
for (; it != en; ++it) {
|
||||
vector<Format const *> r =
|
||||
getReachable(*it, only_viewable, false);
|
||||
FormatList r = getReachable(*it, only_viewable, false);
|
||||
result.insert(result.end(), r.begin(), r.end());
|
||||
}
|
||||
return result;
|
||||
|
@ -31,6 +31,8 @@ class Format;
|
||||
class Formats;
|
||||
class OutputParams;
|
||||
|
||||
typedef std::vector<Format const *> FormatList;
|
||||
|
||||
|
||||
///
|
||||
class Converter {
|
||||
@ -132,16 +134,16 @@ public:
|
||||
//
|
||||
void erase(std::string const & from, std::string const & to);
|
||||
///
|
||||
std::vector<Format const *> const
|
||||
getReachableTo(std::string const & target, bool clear_visited);
|
||||
FormatList const
|
||||
getReachableTo(std::string const & target, bool clear_visited);
|
||||
///
|
||||
std::vector<Format const *> const
|
||||
getReachable(std::string const & from, bool only_viewable,
|
||||
bool clear_visited,
|
||||
std::set<std::string> const & excludes = std::set<std::string>());
|
||||
FormatList const
|
||||
getReachable(std::string const & from, bool only_viewable,
|
||||
bool clear_visited,
|
||||
std::set<std::string> const & excludes = std::set<std::string>());
|
||||
|
||||
std::vector<Format const *> importableFormats();
|
||||
std::vector<Format const *> exportableFormats(bool only_viewable);
|
||||
FormatList importableFormats();
|
||||
FormatList exportableFormats(bool only_viewable);
|
||||
|
||||
std::vector<std::string> loaders() const;
|
||||
std::vector<std::string> savers() const;
|
||||
@ -182,7 +184,7 @@ public:
|
||||
void buildGraph();
|
||||
private:
|
||||
///
|
||||
std::vector<Format const *> const
|
||||
FormatList const
|
||||
intToFormat(std::vector<int> const & input);
|
||||
///
|
||||
bool scanLog(Buffer const & buffer, std::string const & command,
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "Color.h"
|
||||
#include "ColorCache.h"
|
||||
#include "Converter.h"
|
||||
#include "Cursor.h"
|
||||
#include "Encoding.h"
|
||||
#include "FloatPlacement.h"
|
||||
@ -2545,9 +2546,9 @@ void GuiDocument::updateDefaultFormat()
|
||||
outputModule->defaultFormatCO->clear();
|
||||
outputModule->defaultFormatCO->addItem(qt_("Default"),
|
||||
QVariant(QString("default")));
|
||||
vector<Format const *> const & formats = param_copy.exportableFormats(true);
|
||||
vector<Format const *>::const_iterator cit = formats.begin();
|
||||
vector<Format const *>::const_iterator end = formats.end();
|
||||
FormatList const & formats = param_copy.exportableFormats(true);
|
||||
FormatList::const_iterator cit = formats.begin();
|
||||
FormatList::const_iterator end = formats.end();
|
||||
for (; cit != end; ++cit)
|
||||
outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
|
||||
QVariant(toqstr((*cit)->name())));
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "Converter.h"
|
||||
#include "Format.h"
|
||||
#include "FuncRequest.h"
|
||||
|
||||
|
@ -1030,8 +1030,7 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
||||
if (!buf && kind != MenuItem::ImportFormats)
|
||||
return;
|
||||
|
||||
typedef vector<Format const *> Formats;
|
||||
Formats formats;
|
||||
FormatList formats;
|
||||
FuncCode action = LFUN_NOACTION;
|
||||
|
||||
switch (kind) {
|
||||
@ -1067,8 +1066,8 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
||||
MenuItem item(MenuItem::Submenu, smenue);
|
||||
item.setSubmenu(MenuDefinition(smenue));
|
||||
|
||||
Formats::const_iterator fit = formats.begin();
|
||||
Formats::const_iterator end = formats.end();
|
||||
FormatList::const_iterator fit = formats.begin();
|
||||
FormatList::const_iterator end = formats.end();
|
||||
for (; fit != end ; ++fit) {
|
||||
if ((*fit)->dummy())
|
||||
continue;
|
||||
|
@ -194,7 +194,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
|
||||
case TO_IMPORTFORMATS:
|
||||
case TO_UPDATEFORMATS:
|
||||
case TO_VIEWFORMATS: {
|
||||
vector<Format const *> formats = (code == TO_IMPORTFORMATS) ?
|
||||
FormatList formats = (code == TO_IMPORTFORMATS) ?
|
||||
theConverters().importableFormats() :
|
||||
theConverters().exportableFormats(code != TO_EXPORTFORMATS);
|
||||
sort(formats.begin(), formats.end());
|
||||
|
Loading…
Reference in New Issue
Block a user