]> git.lyx.org Git - features.git/commitdiff
fix bug 2153
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 9 Jan 2006 21:00:24 +0000 (21:00 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 9 Jan 2006 21:00:24 +0000 (21:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10718 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/ExternalSupport.C
src/insets/ExternalSupport.h
src/insets/insetbibtex.C
src/insets/insetexternal.C
src/insets/insetgraphics.C
src/insets/insetinclude.C
src/insets/insetnote.C
src/outputparams.C
src/outputparams.h

index 426f9923afd59e252889d42bd626e8939fbb22e4..f9e76eaef73c4bb941c8e5af7707b7d4ae5e1d1e 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-07  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * outputparams.[Ch]: add new flag inComment
+
 2006-01-04  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * text2.C (deleteEmptyParagraphMechanism): since we delete a
index 715c7a273a7ac0ff367142f9270d781a26a9031a..092e271a4fbbb86fc5edb6c3db92ab774043c254 100644 (file)
@@ -1,3 +1,16 @@
+2006-01-07  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * ExternalSupport.[Ch] (updateExternal): add external_in_comment flag
+       * insetexternal.C (latex, linuxdoc, docbook, plaintext): Don't copy
+       files inside comments
+       * insetbibtex.C (latex): ditto
+       * insetinclude.C (latex, linuxdoc, docbook, plaintext): ditto
+       * insetnote.C (latex): set inComment flag in runparams and ignore
+       exported files for comment insets
+       * insetnote.C (linuxdoc): ditto
+       * insetnote.C (docbook): ditto
+       * insetnote.C (plaintext): ditto
+
 2006-01-01    <larsbj@gullik.net>
 
        * insetcharstyle.h: fix syntax error
index 6a64f2867557eddf363ccf46b4fdfe5a4ad5fc9a..93b7f9f212a93b0558c5aebdab1eb65d357cdabe 100644 (file)
@@ -333,7 +333,8 @@ int writeExternal(InsetExternalParams const & params,
                  string const & format,
                  Buffer const & buffer, ostream & os,
                   ExportData & exportdata,
-                 bool external_in_tmpdir)
+                  bool external_in_tmpdir,
+                  bool external_in_comment)
 {
        Template const * const et_ptr = getTemplatePtr(params);
        if (!et_ptr)
@@ -349,7 +350,9 @@ int writeExternal(InsetExternalParams const & params,
                return 0;
        }
 
-       updateExternal(params, format, buffer, exportdata, external_in_tmpdir);
+       if (!external_in_comment)
+               updateExternal(params, format, buffer, exportdata,
+                              external_in_tmpdir);
 
        bool const use_latex_path = format == "LaTeX";
        string str = doSubstitution(params, buffer, cit->second.product,
index 9967c5dbad49b43eec664f41b7fb01248196ce71..6c616bab87765cd720ddae5a4998fd6403a939e0 100644 (file)
@@ -65,7 +65,8 @@ int writeExternal(InsetExternalParams const &,
                  Buffer const &,
                  std::ostream &,
                  ExportData &,
-                 bool external_in_tmpdir = false);
+                  bool external_in_tmpdir,
+                  bool external_in_comment);
 
 } // namespace external
 } // namespace lyx
index 3bc29d0566a09e2c1d67a04325523ad072ea6a6e..259f18ff692e3514cc137b0d7267271a0237d861 100644 (file)
@@ -160,7 +160,8 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
                        normalize_name(buffer, runparams, input, ".bib");
                string const in_file = database + ".bib";
 
-               if (!runparams.nice && IsFileReadable(in_file)) {
+               if (!runparams.inComment && !runparams.nice &&
+                   IsFileReadable(in_file)) {
 
                        database = FileName(database).mangledFilename();
                        string const out_file = MakeAbsPath(database + ".bib",
index 4af98bba7798aaabc06d8a9fd1291caf1e7f6f18..61cc1dca28a57aaccead533a4c983fae3b6ae8cb 100644 (file)
@@ -18,7 +18,6 @@
 #include "insets/render_preview.h"
 
 #include "buffer.h"
-#include "BufferView.h"
 #include "cursor.h"
 #include "debug.h"
 #include "dispatchresult.h"
@@ -706,11 +705,13 @@ int InsetExternal::latex(Buffer const & buf, ostream & os,
                        return external::writeExternal(params_, "PDFLaTeX",
                                                       buf, os,
                                                       *(runparams.exportdata),
-                                                      external_in_tmpdir);
+                                                      external_in_tmpdir,
+                                                      runparams.inComment);
        }
        return external::writeExternal(params_, "LaTeX", buf, os,
                                       *(runparams.exportdata),
-                                      external_in_tmpdir);
+                                      external_in_tmpdir,
+                                      runparams.inComment);
 }
 
 
@@ -718,7 +719,8 @@ int InsetExternal::plaintext(Buffer const & buf, ostream & os,
                         OutputParams const & runparams) const
 {
        return external::writeExternal(params_, "Ascii", buf, os,
-                                      *(runparams.exportdata));
+                                      *(runparams.exportdata), false,
+                                      runparams.inComment);
 }
 
 
@@ -726,7 +728,8 @@ int InsetExternal::linuxdoc(Buffer const & buf, ostream & os,
                            OutputParams const & runparams) const
 {
        return external::writeExternal(params_, "LinuxDoc", buf, os,
-                                      *(runparams.exportdata));
+                                      *(runparams.exportdata), false,
+                                      runparams.inComment);
 }
 
 
@@ -734,7 +737,8 @@ int InsetExternal::docbook(Buffer const & buf, ostream & os,
                           OutputParams const & runparams) const
 {
        return external::writeExternal(params_, "DocBook", buf, os,
-                                      *(runparams.exportdata));
+                                      *(runparams.exportdata), false,
+                                      runparams.inComment);
 }
 
 
index 44a37fd723496af1c9d4f2acaa2690984183e62f..60d3302c4ea84ede154dc8347556d191e22c0aae 100644 (file)
@@ -578,10 +578,11 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
        // of include files
        Buffer const * m_buffer = buf.getMasterBuffer();
 
-       // Return the output name if the file does not exist.
+       // Return the output name if we are inside a comment or the file does
+       // not exist.
        // We are not going to change the extension or using the name of the
        // temporary file, the code is already complicated enough.
-       if (!IsFileReadable(orig_file))
+       if (runparams.inComment || !IsFileReadable(orig_file))
                return params().filename.outputFilename(m_buffer->filePath());
 
        // We place all temporary files in the master buffer's temp dir.
index 5afd3f382273c667b96711b17879f2b54c472540..ea9c3f60288b55c7cfc4dbe62efc6964cda8aaeb 100644 (file)
@@ -359,7 +359,10 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
        lyxerr[Debug::LATEX] << "exportfile:" << exportfile << endl;
        lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
 
-       if (loadIfNeeded(buffer, params_)) {
+       if (runparams.inComment)
+               // Don't try to load or copy the file
+               ;
+       else if (loadIfNeeded(buffer, params_)) {
                Buffer * tmp = bufferlist.getBuffer(included_file);
 
                if (tmp->params().textclass != m_buffer->params().textclass) {
@@ -376,6 +379,7 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
                tmp->markDepClean(m_buffer->temppath());
 
 #ifdef WITH_WARNINGS
+#warning handle non existing files
 #warning Second argument is irrelevant!
 // since only_body is true, makeLaTeXFile will not look at second
 // argument. Should we set it to string(), or should makeLaTeXFile
index affb96bb0ac4471a31cced8673dd0944fe2f8ec2..884e95b207343ccd4add59188ef4965b3fbf4ae4 100644 (file)
@@ -18,6 +18,7 @@
 #include "cursor.h"
 #include "debug.h"
 #include "dispatchresult.h"
+#include "exporter.h"
 #include "funcrequest.h"
 #include "FuncStatus.h"
 #include "gettext.h"
@@ -25,6 +26,7 @@
 #include "LColor.h"
 #include "lyxlex.h"
 #include "metricsinfo.h"
+#include "outputparams.h"
 #include "paragraph.h"
 
 #include "support/lyxalgo.h"
@@ -229,15 +231,19 @@ bool InsetNote::getStatus(LCursor & cur, FuncRequest const & cmd,
 
 
 int InsetNote::latex(Buffer const & buf, ostream & os,
-                    OutputParams const & runparams) const
+                     OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
+       OutputParams runparams(runparams_in);
        string type;
-       if (params_.type == InsetNoteParams::Comment)
+       if (params_.type == InsetNoteParams::Comment) {
                type = "comment";
-       else if (params_.type == InsetNoteParams::Greyedout)
+               runparams.inComment = true;
+               // Ignore files that are exported inside a comment
+               runparams.exportdata.reset(new ExportData);
+       } else if (params_.type == InsetNoteParams::Greyedout)
                type = "lyxgreyedout";
 
        ostringstream ss;
@@ -253,14 +259,19 @@ int InsetNote::latex(Buffer const & buf, ostream & os,
 
 
 int InsetNote::linuxdoc(Buffer const & buf, std::ostream & os,
-                       OutputParams const & runparams) const
+                        OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
+       OutputParams runparams(runparams_in);
        ostringstream ss;
-       if (params_.type == InsetNoteParams::Comment)
+       if (params_.type == InsetNoteParams::Comment) {
                ss << "<comment>\n";
+               runparams.inComment = true;
+               // Ignore files that are exported inside a comment
+               runparams.exportdata.reset(new ExportData);
+       }
 
        InsetText::linuxdoc(buf, ss, runparams);
 
@@ -275,14 +286,19 @@ int InsetNote::linuxdoc(Buffer const & buf, std::ostream & os,
 
 
 int InsetNote::docbook(Buffer const & buf, std::ostream & os,
-                      OutputParams const & runparams) const
+                       OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
+       OutputParams runparams(runparams_in);
        ostringstream ss;
-       if (params_.type == InsetNoteParams::Comment)
+       if (params_.type == InsetNoteParams::Comment) {
                ss << "<remark>\n";
+               runparams.inComment = true;
+               // Ignore files that are exported inside a comment
+               runparams.exportdata.reset(new ExportData);
+       }
 
        InsetText::docbook(buf, ss, runparams);
 
@@ -297,11 +313,17 @@ int InsetNote::docbook(Buffer const & buf, std::ostream & os,
 
 
 int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
-                    OutputParams const & runparams) const
+                         OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
                return 0;
 
+       OutputParams runparams(runparams_in);
+       if (params_.type == InsetNoteParams::Comment) {
+               runparams.inComment = true;
+               // Ignore files that are exported inside a comment
+               runparams.exportdata.reset(new ExportData);
+       }
        ostringstream ss;
        ss << "[";
        InsetText::plaintext(buf, ss, runparams);
index 817f6d95919763f2543912219d845f580ebb0040..8ce11581124f88602d7973fbf16984024a043951 100644 (file)
@@ -18,7 +18,8 @@ OutputParams::OutputParams()
        : flavor(LATEX), nice(false), moving_arg(false),
          local_font(0), free_spacing(false), use_babel(false),
          linelen(0), depth(0),
-         exportdata(new ExportData)
+         exportdata(new ExportData),
+         inComment(false)
 {}
 
 
index c5307ff75eff4374f75af6ba8badc5c9368a939f..40a119d7d25305ff16a87896d0f6b08e9a4a95fa 100644 (file)
@@ -89,6 +89,14 @@ public:
            OutputParams instances.
        */
        boost::shared_ptr<ExportData> exportdata;
+
+       /** Whether we are inside a comment inset. Insets that are including
+        *  external files like InsetGraphics, InsetInclude and InsetExternal
+        *  may only write the usual output and must not attempt to do
+        *  something with the included files (e.g. copying, converting)
+        *  if this flag is true, since they may not exist.
+        */
+       bool inComment;
 };
 
 #endif // NOT OUTPUTPARAMS_H