2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
11 * \file ControlCitation.h
12 * \author Angus Leeming <leeming@lyx.org>
24 #include <utility> // pair
25 #include <vector> // pair
29 /** Launch a file dialog and return the chosen file.
30 filename: a suggested filename.
31 title: the title of the dialog.
33 dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
35 string const browseFile(LyXView *lv, string const & filename,
37 string const & pattern,
38 std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
39 std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
42 /* Wrapper around browseFile which tries to provide a filename
43 relative to relpath. If the relative path is of the form "foo.txt"
44 or "bar/foo.txt", then it is returned as relative. OTOH, if it is
45 of the form "../baz/foo.txt", an absolute path is returned. This is
46 intended to be useful for insets which encapsulate files/
48 string const browseRelFile(LyXView *lv, string const & filename,
49 string const & refpath,
51 string const & pattern,
52 std::pair<string,string> const & dir1 = std::make_pair(string(), string()),
53 std::pair<string,string> const & dir2 = std::make_pair(string(), string()));
56 /// Returns a vector of units that can be used to create a valid LaTeX length.
57 std::vector<string> const getLatexUnits();
60 /** Functions to extract vectors of the first and second elems from a
68 typedef typename Pair::first_type first_type;
69 first_type const & operator()(Pair const & p) { return p.first; }
74 typedef typename Pair::second_type second_type;
75 second_type const & operator()(Pair const & p) { return p.second; }
82 std::vector<typename Pair::first_type> const
83 getFirst(std::vector<Pair> const & pr)
85 std::vector<typename Pair::first_type> tmp(pr.size());
86 std::transform(pr.begin(), pr.end(), tmp.begin(),
87 hide::firster<Pair>());
93 std::vector<typename Pair::second_type> const
94 getSecond(std::vector<Pair> const & pr)
96 std::vector<typename Pair::second_type> tmp(pr.size());
97 std::transform(pr.begin(), pr.end(), tmp.begin(),
98 hide::seconder<Pair>());
103 #endif // HELPERFUNCS_H