2001-03-21 13:27:03 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
2002-03-21 21:21:28 +00:00
|
|
|
* ======================================================
|
2001-03-21 13:27:03 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlCitation.h
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HELPERFUNCS_H
|
|
|
|
#define HELPERFUNCS_H
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
#include <utility> // pair
|
|
|
|
|
2001-03-21 13:27:03 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
class LyXView;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
/** Launch a file dialog and return the chosen file.
|
|
|
|
filename: a suggested filename.
|
|
|
|
title: the title of the dialog.
|
|
|
|
pattern: *.ps etc.
|
|
|
|
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
|
|
|
*/
|
|
|
|
string const browseFile(LyXView *lv, string const & filename,
|
|
|
|
string const & title,
|
2002-03-21 21:21:28 +00:00
|
|
|
string const & pattern,
|
2002-01-13 15:01:25 +00:00
|
|
|
std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
|
|
|
|
std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
|
2001-03-30 09:51:46 +00:00
|
|
|
|
2001-10-15 10:28:31 +00:00
|
|
|
|
2002-01-14 23:31:23 +00:00
|
|
|
/* Wrapper around browseFile which tries to provide a filename
|
|
|
|
relative to relpath. If the relative path is of the form "foo.txt"
|
|
|
|
or "bar/foo.txt", then it is returned as relative. OTOH, if it is
|
|
|
|
of the form "../baz/foo.txt", an absolute path is returned. This is
|
|
|
|
intended to be useful for insets which encapsulate files/
|
|
|
|
*/
|
|
|
|
string const browseRelFile(LyXView *lv, string const & filename,
|
|
|
|
string const & refpath,
|
|
|
|
string const & title,
|
2002-03-21 21:21:28 +00:00
|
|
|
string const & pattern,
|
2002-01-14 23:31:23 +00:00
|
|
|
std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
|
|
|
|
std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
|
|
|
|
|
|
|
|
|
2001-10-15 10:28:31 +00:00
|
|
|
/// Returns a vector of units that can be used to create a valid LaTeX length.
|
|
|
|
std::vector<string> const getLatexUnits();
|
|
|
|
|
|
|
|
|
2001-03-21 13:27:03 +00:00
|
|
|
/** Functions to extract vectors of the first and second elems from a
|
|
|
|
vector<pair<A,B> >
|
|
|
|
*/
|
|
|
|
|
2002-02-18 19:13:48 +00:00
|
|
|
namespace hide {
|
|
|
|
|
2001-03-21 13:27:03 +00:00
|
|
|
template<class Pair>
|
|
|
|
struct firster {
|
|
|
|
typedef typename Pair::first_type first_type;
|
|
|
|
first_type const & operator()(Pair const & p) { return p.first; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Pair>
|
|
|
|
struct seconder {
|
|
|
|
typedef typename Pair::second_type second_type;
|
|
|
|
second_type const & operator()(Pair const & p) { return p.second; }
|
|
|
|
};
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-02-18 19:13:48 +00:00
|
|
|
}
|
2001-03-21 13:27:03 +00:00
|
|
|
|
2001-08-07 16:23:52 +00:00
|
|
|
///
|
2001-03-21 13:27:03 +00:00
|
|
|
template<class Pair>
|
2001-08-07 16:23:52 +00:00
|
|
|
std::vector<typename Pair::first_type> const
|
|
|
|
getFirst(std::vector<Pair> const & pr)
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
2001-08-07 16:23:52 +00:00
|
|
|
std::vector<typename Pair::first_type> tmp(pr.size());
|
2002-02-18 19:13:48 +00:00
|
|
|
std::transform(pr.begin(), pr.end(), tmp.begin(),
|
|
|
|
hide::firster<Pair>());
|
2001-03-21 13:27:03 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2001-08-07 16:23:52 +00:00
|
|
|
///
|
2001-03-21 13:27:03 +00:00
|
|
|
template<class Pair>
|
2001-08-07 16:23:52 +00:00
|
|
|
std::vector<typename Pair::second_type> const
|
|
|
|
getSecond(std::vector<Pair> const & pr)
|
2001-03-21 13:27:03 +00:00
|
|
|
{
|
2001-08-07 16:23:52 +00:00
|
|
|
std::vector<typename Pair::second_type> tmp(pr.size());
|
2002-02-18 19:13:48 +00:00
|
|
|
std::transform(pr.begin(), pr.end(), tmp.begin(),
|
|
|
|
hide::seconder<Pair>());
|
2001-03-21 13:27:03 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HELPERFUNCS_H
|