]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialog.cpp
Some more cleanup of LyXView:
[lyx.git] / src / frontends / Dialog.cpp
1 /**
2  * \file Dialog.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Dialog.h"
14
15 #include "Buffer.h"
16 #include "FuncRequest.h"
17 #include "FuncStatus.h"
18 #include "LyXFunc.h"
19
20 #include "LyXView.h"
21
22
23 namespace lyx {
24 namespace frontend {
25
26
27 Dialog::~Dialog()
28 {}
29
30
31 bool Dialog::canApply() const
32 {
33         FuncRequest const fr(getLfun(), name());
34         FuncStatus const fs(getStatus(fr));
35         return fs.enabled();
36 }
37
38
39 void Dialog::dispatch(FuncRequest const & fr) const
40 {
41         lyxview_->dispatch(fr);
42 }
43
44
45 void Dialog::updateDialog(std::string const & name) const
46 {
47         dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
48 }
49
50
51 void Dialog::disconnect(std::string const & name) const
52 {
53         lyxview_->disconnectDialog(name);
54 }
55
56
57 bool Dialog::isBufferAvailable() const
58 {
59         return lyxview_->buffer() != 0;
60 }
61
62
63 bool Dialog::isBufferReadonly() const
64 {
65         if (!lyxview_->buffer())
66                 return true;
67         return lyxview_->buffer()->isReadonly();
68 }
69
70
71 std::string const Dialog::bufferFilepath() const
72 {
73         return buffer().filePath();
74 }
75
76
77 KernelDocType Dialog::docType() const
78 {
79         if (buffer().isLatex())
80                 return LATEX;
81         if (buffer().isLiterate())
82                 return LITERATE;
83
84         return DOCBOOK;
85 }
86
87
88 BufferView * Dialog::bufferview()
89 {
90         return lyxview_->view();
91 }
92
93
94 BufferView const * Dialog::bufferview() const
95 {
96         return lyxview_->view();
97 }
98
99
100 Buffer & Dialog::buffer()
101 {
102         BOOST_ASSERT(lyxview_->buffer());
103         return *lyxview_->buffer();
104 }
105
106
107 Buffer const & Dialog::buffer() const
108 {
109         BOOST_ASSERT(lyxview_->buffer());
110         return *lyxview_->buffer();
111 }
112
113 } // namespace frontend
114 } // namespace lyx