mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 19:59:46 +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;
|
VSpace defskip;
|
||||||
PDFOptions pdfoptions;
|
PDFOptions pdfoptions;
|
||||||
LayoutFileIndex baseClass_;
|
LayoutFileIndex baseClass_;
|
||||||
/// Caching for exportableFormats, which seems to be slow.
|
FormatList exportableFormatList;
|
||||||
std::vector<Format const *> exportableFormatList;
|
FormatList viewableFormatList;
|
||||||
std::vector<Format const *> viewableFormatList;
|
|
||||||
bool isViewCacheValid;
|
bool isViewCacheValid;
|
||||||
bool isExportCacheValid;
|
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;
|
pimpl_->viewableFormatList : pimpl_->exportableFormatList;
|
||||||
bool & valid = only_viewable ?
|
bool & valid = only_viewable ?
|
||||||
pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
|
pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
|
||||||
@ -2428,12 +2427,12 @@ vector<Format const *> const & BufferParams::exportableFormats(bool only_viewabl
|
|||||||
excludes.insert("latex");
|
excludes.insert("latex");
|
||||||
excludes.insert("pdflatex");
|
excludes.insert("pdflatex");
|
||||||
}
|
}
|
||||||
vector<Format const *> result =
|
FormatList result =
|
||||||
theConverters().getReachable(backs[0], only_viewable, true, excludes);
|
theConverters().getReachable(backs[0], only_viewable, true, excludes);
|
||||||
for (vector<string>::const_iterator it = backs.begin() + 1;
|
for (vector<string>::const_iterator it = backs.begin() + 1;
|
||||||
it != backs.end(); ++it) {
|
it != backs.end(); ++it) {
|
||||||
vector<Format const *> r =
|
FormatList r = theConverters().getReachable(*it, only_viewable,
|
||||||
theConverters().getReachable(*it, only_viewable, false, excludes);
|
false, excludes);
|
||||||
result.insert(result.end(), r.begin(), r.end());
|
result.insert(result.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
sort(result.begin(), result.end(), Format::formatSorter);
|
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
|
bool BufferParams::isExportableFormat(string const & format) const
|
||||||
{
|
{
|
||||||
typedef vector<Format const *> Formats;
|
FormatList const & formats = exportableFormats(true);
|
||||||
Formats const & formats = exportableFormats(true);
|
FormatList::const_iterator fit = formats.begin();
|
||||||
Formats::const_iterator fit = formats.begin();
|
FormatList::const_iterator end = formats.end();
|
||||||
Formats::const_iterator end = formats.end();
|
|
||||||
for (; fit != end ; ++fit) {
|
for (; fit != end ; ++fit) {
|
||||||
if ((*fit)->name() == format)
|
if ((*fit)->name() == format)
|
||||||
return true;
|
return true;
|
||||||
@ -2543,7 +2541,7 @@ string BufferParams::getDefaultOutputFormat() const
|
|||||||
return default_output_format;
|
return default_output_format;
|
||||||
if (isDocBook()
|
if (isDocBook()
|
||||||
|| encoding().package() == Encoding::japanese) {
|
|| encoding().package() == Encoding::japanese) {
|
||||||
vector<Format const *> const & formats = exportableFormats(true);
|
FormatList const & formats = exportableFormats(true);
|
||||||
if (formats.empty())
|
if (formats.empty())
|
||||||
return string();
|
return string();
|
||||||
// return the first we find
|
// return the first we find
|
||||||
|
@ -715,14 +715,13 @@ void Converters::buildGraph()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<Format const *> const
|
FormatList const Converters::intToFormat(vector<int> const & input)
|
||||||
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 it = input.begin();
|
||||||
vector<int>::const_iterator const end = input.end();
|
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) {
|
for ( ; it != end; ++it, ++rit) {
|
||||||
*rit = &formats.get(*it);
|
*rit = &formats.get(*it);
|
||||||
}
|
}
|
||||||
@ -730,8 +729,8 @@ Converters::intToFormat(vector<int> const & input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<Format const *> const
|
FormatList const Converters::getReachableTo(string const & target,
|
||||||
Converters::getReachableTo(string const & target, bool const clear_visited)
|
bool const clear_visited)
|
||||||
{
|
{
|
||||||
vector<int> const & reachablesto =
|
vector<int> const & reachablesto =
|
||||||
G_.getReachableTo(formats.getNumber(target), clear_visited);
|
G_.getReachableTo(formats.getNumber(target), clear_visited);
|
||||||
@ -740,9 +739,9 @@ Converters::getReachableTo(string const & target, bool const clear_visited)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<Format const *> const
|
FormatList const Converters::getReachable(string const & from,
|
||||||
Converters::getReachable(string const & from, bool const only_viewable,
|
bool const only_viewable, bool const clear_visited,
|
||||||
bool const clear_visited, set<string> const & excludes)
|
set<string> const & excludes)
|
||||||
{
|
{
|
||||||
set<int> excluded_numbers;
|
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<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 it = l.begin() + 1;
|
||||||
vector<string>::const_iterator en = l.end();
|
vector<string>::const_iterator en = l.end();
|
||||||
for (; it != en; ++it) {
|
for (; it != en; ++it) {
|
||||||
vector<Format const *> r = getReachableTo(*it, false);
|
FormatList r = getReachableTo(*it, false);
|
||||||
result.insert(result.end(), r.begin(), r.end());
|
result.insert(result.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vector<Format const *> Converters::exportableFormats(bool only_viewable)
|
FormatList Converters::exportableFormats(bool only_viewable)
|
||||||
{
|
{
|
||||||
vector<string> s = savers();
|
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 it = s.begin() + 1;
|
||||||
vector<string>::const_iterator en = s.end();
|
vector<string>::const_iterator en = s.end();
|
||||||
for (; it != en; ++it) {
|
for (; it != en; ++it) {
|
||||||
vector<Format const *> r =
|
FormatList r = getReachable(*it, only_viewable, false);
|
||||||
getReachable(*it, only_viewable, false);
|
|
||||||
result.insert(result.end(), r.begin(), r.end());
|
result.insert(result.end(), r.begin(), r.end());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -31,6 +31,8 @@ class Format;
|
|||||||
class Formats;
|
class Formats;
|
||||||
class OutputParams;
|
class OutputParams;
|
||||||
|
|
||||||
|
typedef std::vector<Format const *> FormatList;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
class Converter {
|
class Converter {
|
||||||
@ -132,16 +134,16 @@ public:
|
|||||||
//
|
//
|
||||||
void erase(std::string const & from, std::string const & to);
|
void erase(std::string const & from, std::string const & to);
|
||||||
///
|
///
|
||||||
std::vector<Format const *> const
|
FormatList const
|
||||||
getReachableTo(std::string const & target, bool clear_visited);
|
getReachableTo(std::string const & target, bool clear_visited);
|
||||||
///
|
///
|
||||||
std::vector<Format const *> const
|
FormatList const
|
||||||
getReachable(std::string const & from, bool only_viewable,
|
getReachable(std::string const & from, bool only_viewable,
|
||||||
bool clear_visited,
|
bool clear_visited,
|
||||||
std::set<std::string> const & excludes = std::set<std::string>());
|
std::set<std::string> const & excludes = std::set<std::string>());
|
||||||
|
|
||||||
std::vector<Format const *> importableFormats();
|
FormatList importableFormats();
|
||||||
std::vector<Format const *> exportableFormats(bool only_viewable);
|
FormatList exportableFormats(bool only_viewable);
|
||||||
|
|
||||||
std::vector<std::string> loaders() const;
|
std::vector<std::string> loaders() const;
|
||||||
std::vector<std::string> savers() const;
|
std::vector<std::string> savers() const;
|
||||||
@ -182,7 +184,7 @@ public:
|
|||||||
void buildGraph();
|
void buildGraph();
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
std::vector<Format const *> const
|
FormatList const
|
||||||
intToFormat(std::vector<int> const & input);
|
intToFormat(std::vector<int> const & input);
|
||||||
///
|
///
|
||||||
bool scanLog(Buffer const & buffer, std::string const & command,
|
bool scanLog(Buffer const & buffer, std::string const & command,
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "ColorCache.h"
|
#include "ColorCache.h"
|
||||||
|
#include "Converter.h"
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
#include "Encoding.h"
|
#include "Encoding.h"
|
||||||
#include "FloatPlacement.h"
|
#include "FloatPlacement.h"
|
||||||
@ -2545,9 +2546,9 @@ void GuiDocument::updateDefaultFormat()
|
|||||||
outputModule->defaultFormatCO->clear();
|
outputModule->defaultFormatCO->clear();
|
||||||
outputModule->defaultFormatCO->addItem(qt_("Default"),
|
outputModule->defaultFormatCO->addItem(qt_("Default"),
|
||||||
QVariant(QString("default")));
|
QVariant(QString("default")));
|
||||||
vector<Format const *> const & formats = param_copy.exportableFormats(true);
|
FormatList const & formats = param_copy.exportableFormats(true);
|
||||||
vector<Format const *>::const_iterator cit = formats.begin();
|
FormatList::const_iterator cit = formats.begin();
|
||||||
vector<Format const *>::const_iterator end = formats.end();
|
FormatList::const_iterator end = formats.end();
|
||||||
for (; cit != end; ++cit)
|
for (; cit != end; ++cit)
|
||||||
outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
|
outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
|
||||||
QVariant(toqstr((*cit)->name())));
|
QVariant(toqstr((*cit)->name())));
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
|
#include "Converter.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
|
@ -1030,8 +1030,7 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
|||||||
if (!buf && kind != MenuItem::ImportFormats)
|
if (!buf && kind != MenuItem::ImportFormats)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
typedef vector<Format const *> Formats;
|
FormatList formats;
|
||||||
Formats formats;
|
|
||||||
FuncCode action = LFUN_NOACTION;
|
FuncCode action = LFUN_NOACTION;
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
@ -1067,8 +1066,8 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
|||||||
MenuItem item(MenuItem::Submenu, smenue);
|
MenuItem item(MenuItem::Submenu, smenue);
|
||||||
item.setSubmenu(MenuDefinition(smenue));
|
item.setSubmenu(MenuDefinition(smenue));
|
||||||
|
|
||||||
Formats::const_iterator fit = formats.begin();
|
FormatList::const_iterator fit = formats.begin();
|
||||||
Formats::const_iterator end = formats.end();
|
FormatList::const_iterator end = formats.end();
|
||||||
for (; fit != end ; ++fit) {
|
for (; fit != end ; ++fit) {
|
||||||
if ((*fit)->dummy())
|
if ((*fit)->dummy())
|
||||||
continue;
|
continue;
|
||||||
|
@ -194,7 +194,7 @@ ToolbarInfo & ToolbarInfo::read(Lexer & lex)
|
|||||||
case TO_IMPORTFORMATS:
|
case TO_IMPORTFORMATS:
|
||||||
case TO_UPDATEFORMATS:
|
case TO_UPDATEFORMATS:
|
||||||
case TO_VIEWFORMATS: {
|
case TO_VIEWFORMATS: {
|
||||||
vector<Format const *> formats = (code == TO_IMPORTFORMATS) ?
|
FormatList formats = (code == TO_IMPORTFORMATS) ?
|
||||||
theConverters().importableFormats() :
|
theConverters().importableFormats() :
|
||||||
theConverters().exportableFormats(code != TO_EXPORTFORMATS);
|
theConverters().exportableFormats(code != TO_EXPORTFORMATS);
|
||||||
sort(formats.begin(), formats.end());
|
sort(formats.begin(), formats.end());
|
||||||
|
Loading…
Reference in New Issue
Block a user