]> git.lyx.org Git - lyx.git/blob - src/insets/insetparent.C
fix #832
[lyx.git] / src / insets / insetparent.C
1 /**
2  * \file insetparent.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11
12 // Created by asierra 970813
13
14 #include <config.h>
15
16 #include "insetparent.h"
17 #include "BufferView.h"
18 #include "frontends/LyXView.h"
19 #include "support/LOstream.h"
20 #include "funcrequest.h"
21 #include "buffer.h"
22 #include "gettext.h"
23
24 #include "support/filetools.h"
25 #include "support/lstrings.h"
26
27 using std::ostream;
28
29
30 InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
31         : InsetCommand(p)
32 {
33         string const fn = p.getContents();
34         setContents(MakeAbsPath(fn, bf.filePath()));
35 }
36
37
38 string const InsetParent::getScreenLabel(Buffer const *) const
39 {
40         return bformat(_("Parent: %1$s"), getContents());
41 }
42
43
44 dispatch_result InsetParent::localDispatch(FuncRequest const & cmd)
45 {
46         switch (cmd.action) {
47                 case LFUN_INSET_EDIT:
48                         cmd.view()->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
49                         return DISPATCHED;
50                 default:
51                         return UNDISPATCHED;
52         }
53 }
54
55
56 // LaTeX must just ignore this command
57 int InsetParent::latex(Buffer const * buf, ostream & os,
58                        bool fragile, bool free_spc) const
59 {
60         os << "%%#{lyx}";
61         InsetCommand::latex(buf, os, fragile, free_spc);
62         return 0;
63 }