]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsCacheItem.C
Store an InsetBase & in MailInset.
[lyx.git] / src / graphics / GraphicsCacheItem.C
index 95092e42d13ef411a144da260858e7417347654b..fe38fd16af8856726d452e06de754127e30b3d6c 100644 (file)
@@ -1,19 +1,17 @@
-/*
+/**
  * \file GraphicsCacheItem.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Baruch Even <baruch.even@writeme.com>
- * \author Herbert Voss <voss@lyx.org>
- * \author Angus Leeming <leeming@lyx.org>
+ * \author Baruch Even
+ * \author Herbert Voss
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "GraphicsCacheItem.h"
 #include "GraphicsImage.h"
 #include "GraphicsConverter.h"
@@ -210,12 +208,12 @@ void CacheItem::Impl::reset()
        zipped_ = false;
        if (!unzipped_filename_.empty())
                lyx::unlink(unzipped_filename_);
-       unzipped_filename_.clear();
+       unzipped_filename_.erase();
 
        if (remove_loaded_file_ && !file_to_load_.empty())
                lyx::unlink(file_to_load_);
        remove_loaded_file_ = false;
-       file_to_load_.clear();
+       file_to_load_.erase();
 
        if (image_.get())
                image_.reset();
@@ -246,7 +244,7 @@ void CacheItem::Impl::setStatus(ImageStatus new_status)
 void CacheItem::Impl::imageConverted(bool success)
 {
        string const text = success ? "succeeded" : "failed";
-       lyxerr[Debug::GRAPHICS] << "Image conversion " << text << "." << endl;
+       lyxerr[Debug::GRAPHICS] << "Image conversion " << text << '.' << endl;
 
        file_to_load_ = converter_.get() ?
                converter_->convertedFile() : string();
@@ -254,9 +252,10 @@ void CacheItem::Impl::imageConverted(bool success)
        cc_.disconnect();
 
        success = !file_to_load_.empty() && IsFileReadable(file_to_load_);
-       lyxerr[Debug::GRAPHICS] << "Unable to find converted file!" << endl;
 
        if (!success) {
+               lyxerr[Debug::GRAPHICS] << "Unable to find converted file!"
+                                       << endl;
                setStatus(ErrorConverting);
 
                if (zipped_)
@@ -288,7 +287,7 @@ void CacheItem::Impl::loadImage()
 void CacheItem::Impl::imageLoaded(bool success)
 {
        string const text = success ? "succeeded" : "failed";
-       lyxerr[Debug::GRAPHICS] << "Image loading " << text << "." << endl;
+       lyxerr[Debug::GRAPHICS] << "Image loading " << text << '.' << endl;
 
        // Clean up after loading.
        if (zipped_)
@@ -323,23 +322,27 @@ string const findTargetFormat(string const & from)
        lyx::Assert(!formats.empty());
 
        // First ascertain if we can load directly with no conversion
-       FormatList::const_iterator it1 = formats.begin();
+       FormatList::const_iterator it  = formats.begin();
        FormatList::const_iterator end = formats.end();
-       for (; it1 != end; ++it1) {
-               if (from == *it1)
-                       return *it1;
+       for (; it != end; ++it) {
+               if (from == *it)
+                       return *it;
        }
 
        // So, we have to convert to a loadable format. Can we?
-       FormatList::const_iterator it2 = formats.begin();
-       for (; it2 != end; ++it2) {
-               if (grfx::Converter::isReachable(from, *it2))
-                       return *it2;
+       it = formats.begin();
+       for (; it != end; ++it) {
+               if (grfx::Converter::isReachable(from, *it))
+                       return *it;
+               else
+                       lyxerr[Debug::GRAPHICS]
+                               << "Unable to convert from " << from
+                               << " to " << *it << std::endl;
        }
 
-       // Failed! so we have to try to convert it to XPM format
+       // Failed! so we have to try to convert it to PPM format
        // with the standard converter
-       return string("xpm");
+       return string("ppm");
 }
 
 } // anon namespace