]> git.lyx.org Git - lyx.git/blob - src/output.cpp
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / output.cpp
1 /**
2  * \file output.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "output.h"
14
15 #include "support/gettext.h"
16
17 #include "frontends/alert.h"
18
19 #include "support/FileName.h"
20 #include "support/filetools.h"
21 #include "support/lstrings.h"
22
23 using namespace std;
24 using namespace lyx::support;
25
26 namespace lyx {
27
28 namespace {
29
30 template<typename OFStream>
31 bool doOpenFileWrite(OFStream & ofs, FileName const & fname)
32 {
33         ofs.open(fname.toSafeFilesystemEncoding(os::CREATE).c_str());
34         if (ofs)
35                 return true;
36         docstring const file = fname.displayName(50);
37         docstring text = bformat(_("Could not open the specified "
38                                                          "document\n%1$s."), file);
39         frontend::Alert::error(_("Could not open file"), text);
40         return false;
41 }
42
43 } // namespace
44
45
46 bool openFileWrite(ofstream & ofs, FileName const & fname)
47 {
48         return doOpenFileWrite(ofs, fname);
49 }
50
51
52 bool openFileWrite(ofdocstream & ofs, FileName const & fname)
53 {
54         return doOpenFileWrite(ofs, fname);
55 }
56
57
58 } // namespace lyx