]> git.lyx.org Git - lyx.git/commitdiff
Revert r26683 and add some comments making it a little clearer what
authorRichard Heck <rgheck@comcast.net>
Wed, 8 Oct 2008 15:07:09 +0000 (15:07 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 8 Oct 2008 15:07:09 +0000 (15:07 +0000)
is going on here.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26814 a592a061-630c-0410-9148-cb99ea01b6c8

src/ConverterCache.cpp
src/Exporter.cpp
src/Mover.cpp
src/Mover.h

index 335de9de241ffb98c796bb3a39d4a1fc43294d9b..813243f48b0ae47db60e43c92860f3fa3fe0b21b 100644 (file)
@@ -287,7 +287,8 @@ void ConverterCache::add(FileName const & orig_from, string const & to_format,
                        return;
                }
                item->checksum = checksum;
-               if (!mover.copy(converted_file, item->cache_name)) {
+               if (!mover.copy(converted_file, item->cache_name,
+                             onlyFilename(item->cache_name.absFilename()))) {
                        LYXERR(Debug::FILES, "Could not copy file " << orig_from << " to "
                                << item->cache_name);
                } else if (!item->cache_name.changePermission(0600)) {
@@ -297,7 +298,8 @@ void ConverterCache::add(FileName const & orig_from, string const & to_format,
        } else {
                CacheItem new_item(orig_from, to_format, timestamp,
                                orig_from.checksum());
-               if (mover.copy(converted_file, new_item.cache_name)) {
+               if (mover.copy(converted_file, new_item.cache_name,
+                             onlyFilename(new_item.cache_name.absFilename()))) {
                        if (!new_item.cache_name.changePermission(0600)) {
                                LYXERR(Debug::FILES, "Could not change file mode"
                                        << new_item.cache_name);
@@ -433,7 +435,8 @@ bool ConverterCache::copy(FileName const & orig_from, string const & to_format,
        CacheItem * const item = pimpl_->find(orig_from, to_format);
        LASSERT(item, /**/);
        Mover const & mover = getMover(to_format);
-       return mover.copy(item->cache_name, dest);
+       return mover.copy(item->cache_name, dest,
+                         onlyFilename(dest.absFilename()));
 }
 
 } // namespace lyx
index 2c9e4e6e455b1eebac5fa44f53b88ff931e0aea7..8546b0a8ca8a76e912f02523611d06ff99adcd7e 100644 (file)
@@ -86,7 +86,7 @@ CopyStatus copyFile(string const & format,
        }
 
        Mover const & mover = getMover(format);
-       if (!mover.copy(sourceFile, destFile))
+       if (!mover.copy(sourceFile, destFile, latexFile))
                Alert::error(_("Couldn't copy file"),
                             bformat(_("Copying %1$s to %2$s failed."),
                                     makeDisplayPath(sourceFile.absFilename()),
index 055c293f1615ba144ded1cad5d5f385622e5c5c2..81d13d2a5df4277aa5d674492fb5d10f146a0f48 100644 (file)
@@ -27,6 +27,13 @@ namespace lyx {
 
 
 bool Mover::copy(FileName const & from, FileName const & to) const
+{
+       return do_copy(from, to, to.absFilename());
+}
+
+
+bool Mover::do_copy(FileName const & from, FileName const & to,
+                   string const &) const
 {
        return from.copyTo(to);
 }
@@ -50,7 +57,7 @@ bool SpecialisedMover::do_copy(FileName const & from, FileName const & to,
                               string const & latex) const
 {
        if (command_.empty())
-               return Mover::copy(from, to);
+               return Mover::do_copy(from, to, latex);
 
        string command = libScriptSearch(command_);
        command = subst(command, "$$i", quoteName(from.toFilesystemEncoding()));
index 1cb9ce6f92d6a00a17049403bb0ea086c223a8fb..4d1c1c79006ff8817e1f02603fd2e11cef72a53c 100644 (file)
@@ -31,17 +31,35 @@ public:
 
        /** Copy file @c from to @c to.
         *  This version should be used to copy files from the original
-        *  location to the temporary directory, since @c to and @c latex
-        *  would be equal in this case.
+        *  location to the temporary directory.
         *  \returns true if successful.
         */
        bool
        copy(support::FileName const & from, support::FileName const & to) const;
 
+       /** Copy file @c from to @c to.
+        *  \see SpecialisedMover::SpecialisedMover() for an explanation of
+        *  @c latex.
+        *  This version should be used to copy files from the temporary
+        *  directory to the export location, since @c to and @c latex may
+        *  not be equal in this case.
+        *  \returns true if successful.
+        *  NOTE: Although this routine simply calls do_copy() and 
+        *  Mover::do_copy() does not itself make any use of the @c latex argument,
+        *  SpecialisedMover overrides do_copy(), so SpecialisedMover::copy(), which
+        *  is just Mover::copy(), calls SpecialisedMover::do_copy(), and the @c latex 
+        *  argument IS in that case used.
+        */
+       bool
+       copy(support::FileName const & from, support::FileName const & to,
+            std::string const & latex) const
+       {
+               return do_copy(from, to, latex);
+       }
+
        /** Rename file @c from as @c to.
         *  This version should be used to move files from the original
-        *  location to the temporary directory, since @c to and @c latex
-        *  would be equal in this case.
+        *  location to the temporary directory.
         *  \returns true if successful.
         */
        bool
@@ -63,6 +81,10 @@ public:
        }
 
 protected:
+       virtual bool
+       do_copy(support::FileName const & from, support::FileName const & to,
+               std::string const &) const;
+
        virtual bool
        do_rename(support::FileName const & from, support::FileName const & to,
                  std::string const &) const;
@@ -76,7 +98,13 @@ protected:
  *  For example, an Xfig .fig file can contain references to external
  *  picture files. If such a reference has a relative path, then the
  *  copied .fig file will require a transformation of the picture file
- *  reference if it is to be found by Xfig.
+ *  reference if it is to be found by Xfig. 
+ *
+ *  So, in this case, we need three arguments: 
+ *  (i)   @c from  the location of the file to be moved
+ *  (ii)  @c to    the location to which it should be moved
+ *  (iii) @c latex the identifier that should be used in the sort of
+ *                 transformation just mentioned.
  */
 class SpecialisedMover : public Mover
 {
@@ -92,14 +120,11 @@ public:
         *  where $$s is a placeholder for the lyx support directory,
         *        $$i is a placeholder for the name of the file to be moved,
         *        $$o is a placeholder for the name of the file after moving,
-        *        $$l is a placeholder for the name of the file after moving,
-        *        suitable as argument to a latex include command. This is
-        *        either an absolute filename or relative to the master
-        *        document.
-        *        $$o and $$l can only differ if the file is copied from the
-        *        temporary directory to the export location. If it is copied
-        *        from the original location to the temporary directory, they
-        *        are the same, so $$l may be ommitted in this case.
+        *        $$l is a placeholder for the latex argument, as explained above.
+        *  $$o and $$l can only differ if the file is copied from the temporary 
+        *  directory to the export location. If it is copied from the original 
+        *  location to the temporary directory, they are the same, so $$l may be 
+        *  ignored in this case, as it is in the Mover baseclass.
         */
        SpecialisedMover(std::string const & command)
                : command_(command) {}