mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Save the document directory path only if explicitly allowed.
A new preference is introduced for allowing the record of the document directory path in the saved file. Without explicit consent, it is not saved. If the origin tag contains an invalid/wrong path or garbage, LyX behaves exactly as before, i.e., included files are simply not found.
This commit is contained in:
parent
be6a6d76af
commit
260a98d295
@ -983,7 +983,8 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
|
||||
// Prints out the buffer info into the .lyx file given by file
|
||||
|
||||
// the document directory
|
||||
os << "\\origin " << buf->filePath() << '\n';
|
||||
os << "\\origin "
|
||||
<< (lyxrc.save_origin ? buf->filePath() : "unavailable") << '\n';
|
||||
|
||||
// the textclass
|
||||
os << "\\textclass " << buf->includedFilePath(addName(buf->layoutPos(),
|
||||
|
@ -172,6 +172,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
|
||||
{ "\\printer", LyXRC::RC_PRINTER },
|
||||
{ "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
|
||||
{ "\\save_origin", LyXRC::RC_SAVE_ORIGIN },
|
||||
{ "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
|
||||
{ "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
|
||||
{ "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
|
||||
@ -295,6 +296,7 @@ void LyXRC::setDefaults()
|
||||
load_session = false;
|
||||
make_backup = true;
|
||||
save_compressed = false;
|
||||
save_origin = false;
|
||||
backupdir_path.erase();
|
||||
display_graphics = true;
|
||||
// Spellchecker settings:
|
||||
@ -987,6 +989,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
||||
case RC_SAVE_COMPRESSED:
|
||||
lexrc >> save_compressed;
|
||||
break;
|
||||
case RC_SAVE_ORIGIN:
|
||||
lexrc >> save_origin;
|
||||
break;
|
||||
case RC_BACKUPDIR_PATH:
|
||||
if (lexrc.next()) {
|
||||
backupdir_path = os::internal_path(lexrc.getString());
|
||||
@ -2424,6 +2429,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_SAVE_ORIGIN:
|
||||
if (ignore_system_lyxrc ||
|
||||
save_origin != system_lyxrc.save_origin) {
|
||||
os << "\\save_origin " << convert<string>(save_origin) << '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_BACKUPDIR_PATH:
|
||||
if (ignore_system_lyxrc ||
|
||||
backupdir_path != system_lyxrc.backupdir_path) {
|
||||
@ -3022,6 +3034,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_PRINT_ADAPTOUTPUT:
|
||||
case LyXRC::RC_PRINT_COMMAND:
|
||||
case LyXRC::RC_SAVE_COMPRESSED:
|
||||
case LyXRC::RC_SAVE_ORIGIN:
|
||||
case LyXRC::RC_SCREEN_DPI:
|
||||
case LyXRC::RC_SCREEN_FONT_ROMAN:
|
||||
case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
|
||||
|
@ -148,6 +148,7 @@ public:
|
||||
RC_PRINT_ADAPTOUTPUT,
|
||||
RC_PRINT_COMMAND,
|
||||
RC_SAVE_COMPRESSED,
|
||||
RC_SAVE_ORIGIN,
|
||||
RC_SCREEN_DPI,
|
||||
RC_SCREEN_FONT_ROMAN,
|
||||
RC_SCREEN_FONT_ROMAN_FOUNDRY,
|
||||
@ -320,6 +321,8 @@ public:
|
||||
bool load_session;
|
||||
/// do we save new documents as compressed by default
|
||||
bool save_compressed;
|
||||
/// whether or not to save the document dir in the file
|
||||
bool save_origin;
|
||||
/// shall a backup file be created
|
||||
bool make_backup;
|
||||
/// A directory for storing backup files
|
||||
|
@ -2628,6 +2628,8 @@ PrefDocHandling::PrefDocHandling(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(saveCompressedCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(saveOriginCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
@ -2639,6 +2641,7 @@ void PrefDocHandling::applyRC(LyXRC & rc) const
|
||||
rc.autosave = autoSaveCB->isChecked() ? autoSaveSB->value() * 60 : 0;
|
||||
rc.make_backup = backupCB->isChecked();
|
||||
rc.save_compressed = saveCompressedCB->isChecked();
|
||||
rc.save_origin = saveOriginCB->isChecked();
|
||||
rc.open_buffers_in_tabs = openDocumentsInTabsCB->isChecked();
|
||||
rc.single_instance = singleInstanceCB->isChecked();
|
||||
rc.single_close_tab_button = singleCloseTabButtonCB->isChecked();
|
||||
@ -2674,6 +2677,7 @@ void PrefDocHandling::updateRC(LyXRC const & rc)
|
||||
autoSaveSB->setEnabled(autosave);
|
||||
backupCB->setChecked(rc.make_backup);
|
||||
saveCompressedCB->setChecked(rc.save_compressed);
|
||||
saveOriginCB->setChecked(rc.save_origin);
|
||||
openDocumentsInTabsCB->setChecked(rc.open_buffers_in_tabs);
|
||||
singleInstanceCB->setChecked(rc.single_instance && !rc.lyxpipes.empty());
|
||||
singleInstanceCB->setEnabled(!rc.lyxpipes.empty());
|
||||
|
@ -149,6 +149,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="saveOriginCB">
|
||||
<property name="toolTip">
|
||||
<string>If this is checked, the document directory path will be saved in the document.
This allows moving the document elsewhere and still finding the included files.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save the &document directory path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -261,6 +271,7 @@
|
||||
<tabstop>autoSaveCB</tabstop>
|
||||
<tabstop>autoSaveSB</tabstop>
|
||||
<tabstop>saveCompressedCB</tabstop>
|
||||
<tabstop>saveOriginCB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
|
Loading…
Reference in New Issue
Block a user