1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 1997 LyX Team (this file was created this year)
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 10:58:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#ifndef INSET_INCLUDE_H
|
|
|
|
#define INSET_INCLUDE_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetcommand.h"
|
|
|
|
#include "buffer.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
struct LaTeXFeatures;
|
|
|
|
|
|
|
|
// Created by AAS 970521
|
|
|
|
|
|
|
|
/** Used to include files
|
|
|
|
*/
|
|
|
|
class InsetInclude: public InsetCommand {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
InsetInclude(): InsetCommand("include")
|
|
|
|
{
|
|
|
|
flag = InsetInclude::INCLUDE;
|
|
|
|
}
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
InsetInclude(string const &, Buffer *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
~InsetInclude();
|
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
Inset * Clone() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
|
|
|
|
/// This returns the list of labels on the child buffer
|
2000-05-19 16:46:01 +00:00
|
|
|
std::vector<string> getLabelList() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// This returns the list of bibkeys on the child buffer
|
2000-06-07 08:53:40 +00:00
|
|
|
std::vector< std::pair<string,string> > getKeys() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-03-08 13:52:57 +00:00
|
|
|
EDITABLE Editable() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-08 13:52:57 +00:00
|
|
|
return IS_EDITABLE;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
/// With lyx3 we won't overload these 3 methods
|
2000-06-12 11:27:15 +00:00
|
|
|
void Write(Buffer const *, std::ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void Read(Buffer const *, LyXLex &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-07-01 12:54:45 +00:00
|
|
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
|
|
|
int DocBook(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
void Validate(LaTeXFeatures &) const;
|
|
|
|
|
|
|
|
/// Input inserts anything inside a paragraph, Display can give some visual feedback
|
2000-04-04 00:19:15 +00:00
|
|
|
bool display() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string getScreenLabel() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void setContents(string const & c);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setFilename(string const & n) { setContents(n); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
string getMasterFilename() const { return master->fileName(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string getFileName() const {
|
1999-09-27 18:44:28 +00:00
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
/// In "input" mode uses \input instead of \include.
|
1999-11-04 01:40:20 +00:00
|
|
|
bool isInput() const { return flag == InsetInclude::INPUT; }
|
1999-09-27 18:44:28 +00:00
|
|
|
/// If this is true, the child file shouldn't be loaded by lyx
|
1999-11-04 01:40:20 +00:00
|
|
|
bool isNoLoad() const { return noload; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** A verbatim file shouldn't be loaded by LyX
|
|
|
|
* No need to generate LaTeX code of a verbatim file
|
|
|
|
*/
|
|
|
|
bool isVerb() const;
|
|
|
|
///
|
1999-11-15 10:58:38 +00:00
|
|
|
bool isVerbVisibleSpace() const { return flag == InsetInclude::VERBAST;}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
bool isInclude() const { return flag == InsetInclude::INCLUDE;}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void setInput();
|
|
|
|
///
|
|
|
|
void setNoLoad(bool);
|
|
|
|
///
|
|
|
|
void setInclude();
|
|
|
|
///
|
|
|
|
void setVerb();
|
|
|
|
///
|
|
|
|
void setVisibleSpace(bool b);
|
|
|
|
/// return true if the file is or got loaded.
|
|
|
|
bool loadIfNeeded() const;
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
enum Include_Flags {
|
|
|
|
///
|
1999-11-15 10:58:38 +00:00
|
|
|
INCLUDE= 0,
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
VERB = 1,
|
|
|
|
///
|
|
|
|
INPUT = 2,
|
|
|
|
///
|
|
|
|
VERBAST = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
bool noload;
|
|
|
|
///
|
|
|
|
int flag;
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
Buffer * master;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string filename;
|
2000-07-01 12:54:45 +00:00
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
mutable string include_label;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool InsetInclude::isVerb() const
|
|
|
|
{
|
1999-12-13 00:05:34 +00:00
|
|
|
return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void InsetInclude::setInput()
|
|
|
|
{
|
|
|
|
if (!isInput()) {
|
|
|
|
flag = InsetInclude::INPUT;
|
|
|
|
setCmdName("input");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void InsetInclude::setNoLoad(bool b)
|
|
|
|
{
|
|
|
|
noload = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void InsetInclude::setInclude()
|
|
|
|
{
|
|
|
|
if (!isInclude()) {
|
|
|
|
flag = InsetInclude::INCLUDE;
|
|
|
|
setCmdName("include");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void InsetInclude::setVerb()
|
|
|
|
{
|
|
|
|
if (!isVerb()) {
|
|
|
|
flag = InsetInclude::VERB;
|
|
|
|
setCmdName("verbatiminput");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void InsetInclude::setVisibleSpace(bool b)
|
|
|
|
{
|
1999-11-15 10:58:38 +00:00
|
|
|
if (b && flag == InsetInclude::VERB) {
|
1999-09-27 18:44:28 +00:00
|
|
|
setCmdName("verbatiminput*");
|
|
|
|
flag = InsetInclude::VERBAST;
|
1999-11-15 10:58:38 +00:00
|
|
|
} else if (!b && flag == InsetInclude::VERBAST) {
|
1999-09-27 18:44:28 +00:00
|
|
|
setCmdName("verbatiminput");
|
|
|
|
flag = InsetInclude::VERB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|