support for default master document.

file format change.

This is the last feature for today. Promised.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24540 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-04-28 16:38:56 +00:00
parent 4f81d0eff7
commit 764b5cf859
9 changed files with 144 additions and 19 deletions

View File

@ -1,6 +1,9 @@
LyX file-format changes
-----------------------
2008-04-28 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* Format incremented to 329: new param \master.
2008-04-18 Bo Peng <ben.bob@gmail.com>
* Format incremented to 328: Revert the support for embedding

View File

@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
("1_6", range(277,329), minor_versions("1.6" , 0))] # Uwe: support for Spanish(Mexico)
("1_6", range(277,330), minor_versions("1.6" , 0))]
def formats_list():

View File

@ -1977,7 +1977,7 @@ def revert_pdfpages(document):
def revert_mexican(document):
"Set language Spanish(Mexico) to Spanish"
' Set language Spanish(Mexico) to Spanish '
i = 0
if document.language == "spanish-mexico":
document.language = "spanish"
@ -1994,13 +1994,20 @@ def revert_mexican(document):
def remove_embedding(document):
' Remove embed tag from all insets'
' Remove embed tag from all insets '
revert_inset_embedding(document, 'Graphics')
revert_inset_embedding(document, 'External')
revert_inset_embedding(document, 'CommandInset include')
revert_inset_embedding(document, 'CommandInset bibtex')
def revert_master(document):
' Remove master param '
i = find_token(document.header, "\\master", 0)
if i != -1:
del document.header[i]
##
# Conversion hub
#
@ -2058,9 +2065,11 @@ convert = [[277, [fix_wrong_tables]],
[326, []],
[327, []],
[328, [remove_embedding, remove_extra_embedded_files, remove_inzip_options]],
[329, []],
]
revert = [[327, []],
revert = [[328, [revert_master]],
[327, []],
[326, [revert_mexican]],
[325, [revert_pdfpages]],
[324, []],

View File

@ -115,7 +115,7 @@ namespace os = support::os;
namespace {
int const LYX_FORMAT = 328;
int const LYX_FORMAT = 329;
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@ -441,6 +441,7 @@ int Buffer::readHeader(Lexer & lex)
params().branchlist().clear();
params().preamble.erase();
params().options.erase();
params().master.erase();
params().float_placement.erase();
params().paperwidth.erase();
params().paperheight.erase();
@ -550,6 +551,15 @@ bool Buffer::readDocument(Lexer & lex)
}
}
if (!params().master.empty()) {
FileName const master_file = makeAbsPath(params().master,
onlyPath(absFileName()));
if (isLyXFilename(master_file.absFilename())) {
Buffer * master = checkAndLoadLyXFile(master_file);
d->parent_buffer = master;
}
}
// read main text
bool const res = text().read(*this, lex, errorList, &(d->inset));

View File

@ -497,6 +497,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
} else if (token == "\\options") {
lex.eatLine();
options = lex.getString();
} else if (token == "\\master") {
lex.eatLine();
master = lex.getString();
} else if (token == "\\language") {
readLanguage(lex);
} else if (token == "\\inputencoding") {
@ -688,6 +691,11 @@ void BufferParams::writeFile(ostream & os) const
if (!options.empty()) {
os << "\\options " << options << '\n';
}
// the master document
if (!master.empty()) {
os << "\\master " << master << '\n';
}
//the modules
if (!layoutModules_.empty()) {

View File

@ -223,6 +223,8 @@ public:
///
std::string options;
///
std::string master;
///
std::string float_placement;
///
unsigned int columns;

View File

@ -876,6 +876,12 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(latexModule->layoutPB, SIGNAL(clicked()),
this, SLOT(browseLayout()));
connect(latexModule->childDocGB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(latexModule->childDocLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(latexModule->childDocPB, SIGNAL(clicked()),
this, SLOT(browseMaster()));
selectionManager =
new ModuleSelMan(latexModule->availableLV, latexModule->selectedLV,
@ -1262,6 +1268,20 @@ void GuiDocument::browseLayout()
}
void GuiDocument::browseMaster()
{
QString const title = qt_("Select master document");
QString const dir1 = toqstr(lyxrc.document_path);
QString const old = latexModule->childDocLE->text();
QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
QStringList const filter(qt_("LyX Files (*.lyx)"));
QString file = browseRelFile(old, docpath, title, filter, false,
qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
latexModule->childDocLE->setText(file);
}
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
@ -1610,6 +1630,12 @@ void GuiDocument::apply(BufferParams & params)
params.options =
fromqstr(latexModule->optionsLE->text());
if (latexModule->childDocGB->isChecked())
params.master =
fromqstr(latexModule->childDocLE->text());
else
params.master = string();
params.float_placement = floatModule->get();
// fonts
@ -1901,6 +1927,15 @@ void GuiDocument::updateParams(BufferParams const & params)
latexModule->optionsLE->setText(QString());
}
if (!params.master.empty()) {
latexModule->childDocGB->setChecked(true);
latexModule->childDocLE->setText(
toqstr(params.master));
} else {
latexModule->childDocLE->setText(QString());
latexModule->childDocGB->setChecked(false);
}
floatModule->set(params.float_placement);
// Fonts
@ -2201,6 +2236,15 @@ void GuiDocument::dispatchParams()
// and then update the buffer's layout.
dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
if (!params().master.empty()) {
FileName const master_file = support::makeAbsPath(params().master,
support::onlyPath(buffer().absFileName()));
if (isLyXFilename(master_file.absFilename())) {
Buffer * master = checkAndLoadLyXFile(master_file);
buffer().setParent(master);
}
}
// Generate the colours requested by each new branch.
BranchList & branchlist = params().branchlist();
if (!branchlist.empty()) {

View File

@ -135,6 +135,7 @@ private Q_SLOTS:
void enableSkip(bool);
void portraitChanged();
void browseLayout();
void browseMaster();
void classChanged();
void updateModuleInfo();

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>375</height>
<height>413</height>
</rect>
</property>
<property name="windowTitle" >
@ -19,20 +19,55 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="4" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="4" >
<widget class="QGroupBox" name="childDocGB" >
<property name="toolTip" >
<string>Select if the current document is included to a master file</string>
</property>
<property name="statusTip" >
<string/>
</property>
<property name="title" >
<string>Select de&amp;fault master document</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="childDocLA" >
<property name="text" >
<string>&amp;Master:</string>
</property>
<property name="buddy" >
<cstring>childDocLE</cstring>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="childDocPB" >
<property name="text" >
<string>&amp;Browse...</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="childDocLE" >
<property name="toolTip" >
<string>Enter the name of the default master document</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="4" >
<widget class="QGroupBox" name="modulesGB" >
<property name="title" >
<string>Modules</string>
@ -203,6 +238,19 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>