1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 LyX Team (this file was created this year)
|
|
|
|
*
|
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 is 1 if the childs have labels, 0 otherwise
|
|
|
|
int GetNumberOfLabels() const;
|
|
|
|
/// This returns the list of labels on the child buffer
|
1999-10-02 16:21:10 +00:00
|
|
|
string getLabel(int) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// This returns the list of bibkeys on the child buffer
|
1999-12-22 14:35:05 +00:00
|
|
|
string getKeys(char delim) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void Edit(int, int);
|
|
|
|
///
|
|
|
|
unsigned char Editable() const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/// With lyx3 we won't overload these 3 methods
|
2000-02-18 22:22:42 +00:00
|
|
|
void Write(ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void Read(LyXLex &);
|
|
|
|
///
|
2000-02-18 22:22:42 +00:00
|
|
|
int Latex(ostream &, signed char fragile) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-18 22:22:42 +00:00
|
|
|
int Latex(string & file, signed char fragile) 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
|
1999-11-22 16:19:48 +00:00
|
|
|
bool display() const { return !(isInput()); }
|
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
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
void setContents(string const & c) {
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetCommand::setContents(c);
|
|
|
|
filename = MakeAbsPath(contents,
|
|
|
|
OnlyPath(getMasterFilename()));
|
|
|
|
}
|
|
|
|
///
|
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;
|
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
|