2 * \file ControlEmbeddedFiles.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ControlEmbeddedFiles.h"
17 #include "FuncRequest.h"
23 #include "frontend_helpers.h"
24 #include "frontends/LyXView.h"
26 #include "support/FileFilterList.h"
27 #include "support/convert.h"
33 using support::FileFilterList;
37 ControlEmbeddedFiles::ControlEmbeddedFiles(Dialog & parent)
42 EmbeddedFiles & ControlEmbeddedFiles::embeddedFiles()
44 return buffer().embeddedFiles();
48 bool ControlEmbeddedFiles::initialiseParams(string const &)
54 void ControlEmbeddedFiles::updateEmbeddedFiles()
56 // copy buffer embeddedFiles to a local copy
57 buffer().embeddedFiles().update();
58 buffer().embeddingChanged();
62 void ControlEmbeddedFiles::dispatchMessage(string const & msg)
64 // FIXME: the right thing to do? QT guys?
65 // lyx view will only be updated if we do something to the main window. :-)
66 dispatch(FuncRequest(LFUN_MESSAGE, msg));
70 void ControlEmbeddedFiles::goTo(EmbeddedFile const & item, int idx)
72 BOOST_ASSERT(idx < item.refCount());
73 item.saveBookmark(&buffer(), idx);
74 lyxview().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"));
78 void ControlEmbeddedFiles::view(EmbeddedFile const & item)
80 formats.view(buffer(), item, formats.getFormatFromFile(item));
84 void ControlEmbeddedFiles::setEmbed(EmbeddedFile & item, bool embed)
86 // FIXME: updateFromExternalFile() or extract() may fail...
88 item.updateFromExternalFile(&buffer());
90 item.extract(&buffer());
95 docstring const ControlEmbeddedFiles::browseFile()
97 std::pair<docstring, docstring> dir1(_("Documents|#o#O"),
98 from_utf8(lyxrc.document_path));
99 FileFilterList const filter(_("All file (*.*)"));
100 return browseRelFile(docstring(), from_utf8(bufferFilepath()),
101 _("Select a file to embed"),
102 filter, false, dir1);
106 bool ControlEmbeddedFiles::extract(EmbeddedFile const & item)
109 return item.extract(&buffer());
115 bool ControlEmbeddedFiles::update(EmbeddedFile const & item)
118 return item.updateFromExternalFile(&buffer());
123 } // namespace frontend