2003-06-20 12:46:28 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/* \file buffer_funcs.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-06-20 12:46:28 +00:00
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-06-20 12:46:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2003-06-24 20:42:15 +00:00
|
|
|
|
#ifndef BUFFER_FUNCS_H
|
|
|
|
|
#define BUFFER_FUNCS_H
|
|
|
|
|
|
2005-02-25 11:55:36 +00:00
|
|
|
|
#include "lyxlayout_ptr_fwd.h"
|
2006-10-20 20:30:00 +00:00
|
|
|
|
#include "support/docstring.h"
|
2005-02-25 11:55:36 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
namespace support { class FileName; }
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2003-06-20 12:46:28 +00:00
|
|
|
|
class Buffer;
|
2004-12-27 16:30:27 +00:00
|
|
|
|
class DocIterator;
|
2003-06-24 20:42:15 +00:00
|
|
|
|
class ErrorList;
|
2004-12-27 16:30:27 +00:00
|
|
|
|
class TeXErrors;
|
2006-04-07 22:16:09 +00:00
|
|
|
|
class ParIterator;
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
2007-08-06 04:14:26 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if the file is already loaded into a buffer.
|
|
|
|
|
*/
|
|
|
|
|
bool checkIfLoaded(support::FileName const & fn);
|
|
|
|
|
|
2003-06-20 12:46:28 +00:00
|
|
|
|
/**
|
2003-09-09 18:27:24 +00:00
|
|
|
|
* Loads a LyX file \c filename into \c Buffer
|
2003-06-20 12:46:28 +00:00
|
|
|
|
* and \return success status.
|
|
|
|
|
*/
|
2006-12-02 16:07:15 +00:00
|
|
|
|
bool loadLyXFile(Buffer *, support::FileName const & filename);
|
2003-06-20 12:46:28 +00:00
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* Checks and loads a LyX file \param filename.
|
|
|
|
|
* \retval the newly created \c Buffer pointer if successful or 0.
|
|
|
|
|
* \retval 0 if the \c Buffer could not be created.
|
|
|
|
|
*/
|
|
|
|
|
Buffer * checkAndLoadLyXFile(support::FileName const & filename);
|
|
|
|
|
|
2007-08-06 04:14:26 +00:00
|
|
|
|
/** Make a new file (buffer) with name \c filename based on a template
|
|
|
|
|
* named \c templatename
|
2003-06-20 12:46:28 +00:00
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Buffer * newFile(std::string const & filename, std::string const & templatename,
|
2003-06-20 12:46:28 +00:00
|
|
|
|
bool isNamed = false);
|
2003-06-24 20:42:15 +00:00
|
|
|
|
|
|
|
|
|
///return the format of the buffer on a string
|
2006-04-09 00:26:19 +00:00
|
|
|
|
std::string const bufferFormat(Buffer const & buffer);
|
2006-08-13 16:16:43 +00:00
|
|
|
|
|
|
|
|
|
/// Fill in the ErrorList with the TeXErrors
|
|
|
|
|
void bufferErrors(Buffer const &, TeXErrors const &, ErrorList &);
|
2003-06-24 20:42:15 +00:00
|
|
|
|
|
2004-12-27 16:30:27 +00:00
|
|
|
|
/// Count the number of words in the text between these two iterators
|
|
|
|
|
int countWords(DocIterator const & from, DocIterator const & to);
|
|
|
|
|
|
2006-04-16 14:19:25 +00:00
|
|
|
|
/// updates all counters
|
2006-11-13 16:53:49 +00:00
|
|
|
|
void updateLabels(Buffer const &, bool childonly = false);
|
2004-12-27 16:30:27 +00:00
|
|
|
|
|
2007-08-12 21:43:58 +00:00
|
|
|
|
///
|
|
|
|
|
void updateLabels(Buffer const &, ParIterator &);
|
|
|
|
|
|
2007-03-12 11:23:41 +00:00
|
|
|
|
///
|
|
|
|
|
void checkBufferStructure(Buffer &, ParIterator const &);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This first patch does some reworking of the infrastructrue. We need to distinguish between the TextClass that a particular document is using and the layout of that document, since modules, in particular, can modify the layout. The solution adopted here is to add a TextClass pointer to BufferParams, which will hold the layout. The layout itself is then constructed from the TextClass the document is using. At present, this is completely trivial, but that will change when modules are added.
The pointer in question is a boost::shared_ptr. This is needed because CutAndPaste saves a copy of the layout with each cut or copied selection. We cannot assume the selection vanishes when the document is closed, so there are two options: (i) keep a list of all the layouts that have ever been used by any document; (ii) used some kind of smart pointer. The latter seems preferable, as the former would waste memory. More importantly, the use of a smart pointer allows modules to be modified on disk and then reloaded while LyX is running, and it will eventually allow the same for layout files.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19756 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-23 16:41:13 +00:00
|
|
|
|
///
|
|
|
|
|
textclass_type defaultTextclass();
|
|
|
|
|
|
2007-08-13 18:11:43 +00:00
|
|
|
|
///
|
|
|
|
|
void loadChildDocuments(Buffer const & buffer);
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2003-06-24 20:42:15 +00:00
|
|
|
|
#endif // BUFFER_FUNCS_H
|