]> git.lyx.org Git - lyx.git/blob - src/Compare.cpp
Try to deal with one of the big problems here, namely, that we
[lyx.git] / src / Compare.cpp
1 /**
2  * \file Compare.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Vincent van Ravesteijn
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Compare.h"
14
15 #include "Buffer.h"
16 #include "BufferParams.h"
17
18
19 using namespace std;
20 using namespace lyx::support;
21
22
23 namespace lyx {
24
25 /**
26  * The implementation of the algorithm that does the comparison
27  * between two documents.
28  */
29 class Compare::Impl {
30 public:
31         ///
32         Impl(Compare const & compare) 
33                 : compare_(compare), abort_(false)
34         {}
35
36         ///
37         ~Impl() {}
38
39         /// Set to true to abort the algorithm
40         bool abort_;
41
42 private:
43         /// The thread object, used to emit signals to the GUI
44         Compare const & compare_;
45 };
46
47
48 Compare::Compare(Buffer const * new_buf, Buffer const * old_buf,
49         Buffer * const dest_buf, CompareOptions const & options)
50         : new_buffer(new_buf), old_buffer(old_buf), dest_buffer(dest_buf),
51           options_(options), pimpl_(new Impl(*this))
52 {
53 }
54
55
56 void Compare::run()
57 {
58         if (!dest_buffer || !new_buffer || !old_buffer) {
59                 error();
60                 return;
61         }
62
63         // Copy the buffer params to the new buffer
64         dest_buffer->params() = options_.settings_from_new
65                 ? new_buffer->params() : old_buffer->params();
66         
67         // do the real work
68         if (!doCompare())
69                 error();
70         else
71                 finished(pimpl_->abort_);
72         return;
73 }
74
75
76 void Compare::abort()
77 {
78         pimpl_->abort_ = true;
79         condition_.wakeOne();
80         wait();
81         pimpl_->abort_ = false;
82 }
83
84
85 int Compare::doCompare()
86 {
87         return 0;
88 }
89
90
91 #include "moc_Compare.cpp"
92
93 } // namespace lyx