tufte layout files:
[lyx.git] / src / Compare.cpp
blob745b3218a3bf84aa8a39e0916e4ce9d667a74434
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.
6 * \author Vincent van Ravesteijn
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "Compare.h"
15 #include "Buffer.h"
16 #include "BufferParams.h"
19 using namespace std;
20 using namespace lyx::support;
23 namespace lyx {
25 /**
26 * The implementation of the algorithm that does the comparison
27 * between two documents.
29 class Compare::Impl {
30 public:
31 ///
32 Impl(Compare const & compare)
33 : abort_(false), compare_(compare)
36 ///
37 ~Impl() {}
39 /// Set to true to abort the algorithm
40 bool abort_;
42 private:
43 /// The thread object, used to emit signals to the GUI
44 Compare const & compare_;
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))
56 void Compare::run()
58 if (!dest_buffer || !new_buffer || !old_buffer) {
59 error();
60 return;
63 // Copy the buffer params to the new buffer
64 dest_buffer->params() = options_.settings_from_new
65 ? new_buffer->params() : old_buffer->params();
67 // do the real work
68 if (!doCompare())
69 error();
70 else
71 finished(pimpl_->abort_);
72 return;
76 void Compare::abort()
78 pimpl_->abort_ = true;
79 condition_.wakeOne();
80 wait();
81 pimpl_->abort_ = false;
85 int Compare::doCompare()
87 return 0;
91 #include "moc_Compare.cpp"
93 } // namespace lyx