#include "insets/ExternalSupport.h"
#include "insets/ExternalTemplate.h"
+#include "support/filefilterlist.h"
#include "support/filetools.h"
-#include "support/tostr.h"
-
-namespace external = lyx::external;
-
-using lyx::support::MakeAbsPath;
-using lyx::support::readBB_from_PSFile;
+#include "support/convert.h"
+using std::advance;
using std::vector;
using std::string;
+namespace lyx {
+
+using support::FileFilterList;
+using support::MakeAbsPath;
+using support::readBB_from_PSFile;
+
+namespace frontend {
+
ControlExternal::ControlExternal(Dialog & parent)
: Dialog::Controller(parent),
string const lfun = InsetExternalMailer::params2string(params(),
kernel().buffer());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
external::TemplateManager::Templates::const_iterator i1
= external::TemplateManager::get().getTemplates().begin();
- std::advance(i1, i);
+ advance(i1, i);
return i1->second;
}
-string const ControlExternal::Browse(string const & input) const
+string const ControlExternal::browse(string const & input,
+ string const & template_name) const
{
string const title = _("Select external file");
string const bufpath = kernel().bufferFilepath();
/// Determine the template file extension
- string pattern = "*";
+ external::TemplateManager const & etm =
+ external::TemplateManager::get();
external::Template const * const et_ptr =
- external::getTemplatePtr(params());
- if (et_ptr)
- pattern = et_ptr->fileRegExp;
+ etm.getTemplateByName(template_name);
+
+ FileFilterList const filter = et_ptr ?
+ FileFilterList(et_ptr->fileRegExp) :
+ FileFilterList();
std::pair<string, string> dir1(N_("Documents|#o#O"),
- string(lyxrc.document_path));
+ string(lyxrc.document_path));
- return browseRelFile(input, bufpath, title, pattern, false, dir1);
+ return browseRelFile(input, bufpath, title, filter, false, dir1);
}
int width = 0;
int height = 0;
- lyx::graphics::Cache & gc = lyx::graphics::Cache::get();
+ graphics::Cache & gc = graphics::Cache::get();
if (gc.inCache(abs_file)) {
- lyx::graphics::Image const * image = gc.item(abs_file)->image();
+ graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
width = image->getWidth();
}
}
- return ("0 0 " + tostr(width) + ' ' + tostr(height));
+ return ("0 0 " + convert<string>(width) + ' ' + convert<string>(height));
}
+} // namespace frontend
+
+
+namespace external {
namespace {
-external::RotationDataType origins_array[] = {
- external::RotationData::DEFAULT,
- external::RotationData::TOPLEFT,
- external::RotationData::BOTTOMLEFT,
- external::RotationData::BASELINELEFT,
- external::RotationData::CENTER,
- external::RotationData::TOPCENTER,
- external::RotationData::BOTTOMCENTER,
- external::RotationData::BASELINECENTER,
- external::RotationData::TOPRIGHT,
- external::RotationData::BOTTOMRIGHT,
- external::RotationData::BASELINERIGHT
+RotationDataType origins_array[] = {
+ RotationData::DEFAULT,
+ RotationData::TOPLEFT,
+ RotationData::BOTTOMLEFT,
+ RotationData::BASELINELEFT,
+ RotationData::CENTER,
+ RotationData::TOPCENTER,
+ RotationData::BOTTOMCENTER,
+ RotationData::BASELINECENTER,
+ RotationData::TOPRIGHT,
+ RotationData::BOTTOMRIGHT,
+ RotationData::BASELINERIGHT
};
-lyx::size_type const origins_array_size =
+
+size_type const origins_array_size =
sizeof(origins_array) / sizeof(origins_array[0]);
-vector<external::RotationDataType> const
+vector<RotationDataType> const
origins(origins_array, origins_array + origins_array_size);
// These are the strings, corresponding to the above, that the GUI should
} // namespace anon
-namespace lyx {
-namespace external {
vector<RotationDataType> const & all_origins()
{
string const origin_gui_str(size_type i)
{
- return origin_gui_strs[i];
+ return _(origin_gui_strs[i]);
}
} // namespace external