+2002-04-11 Herbert Voss <voss@perce.de>
+
+ * ControlGraphics.C: read BoundingBox also from non (e)ps files.
+
2002-04-08 Adrien Rebollo <adrien.rebollo@gmx.fr>
* ControlAboutlyx.C (getVersion): two _() forgotten
#include "ButtonControllerBase.h"
#include "ControlGraphics.h"
#include "ControlInset.tmpl"
+
+#include "helper_funcs.h"
+
#include "buffer.h"
#include "BufferView.h"
#include "Dialogs.h"
#include "gettext.h"
#include "lyxrc.h"
+#include "graphics/GraphicsCache.h"
+
#include "insets/insetgraphics.h"
-#include "insets/insetgraphicsParams.h" // need operator!=()
+#include "insets/insetgraphicsParams.h"
-#include "support/FileInfo.h" // for FileInfo
-#include "helper_funcs.h"
#include "support/lstrings.h"
-#include "support/filetools.h" // for AddName, zippedFile
+#include "support/filetools.h"
+#include "support/FileInfo.h"
+
using std::pair;
using std::make_pair;
using std::ifstream;
-
+
ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
: ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
{
string const ControlGraphics::readBB(string const & file)
{
- return readBB_from_PSFile(MakeAbsPath(file, lv_.buffer()->filePath()));
+ string const abs_file = MakeAbsPath(file, lv_.buffer()->filePath());
+
+ string const from = getExtFromContents(abs_file);
+ // Check if we have a Postscript file, then it's easy
+ if (contains(from, "ps"))
+ return readBB_from_PSFile(abs_file);
+
+ // we don't, so ask the Graphics Cache if it has loaded the file
+ grfx::GCache & gc = grfx::GCache::get();
+ return ("0 0 " +
+ tostr(gc.raw_width(abs_file)) + ' ' +
+ tostr(gc.raw_height(abs_file)));
}
+2002-04-10 Herbert Voss <voss@perce.de>
+
+ * GraphicsCache.[Ch]:
+ * GraphicsCacheItem.[Ch]: add width/height functions from Angus
+ to read the "Bounding Box" from non (e)ps files.
+
2002-04-08 Angus Leeming <a.leeming@ic.ac.uk>
* GraphicsParams.C (c-tor): if clipping, then check the Bounding Box of
return cache->end();
}
+
+unsigned int GCache::raw_width(string const & filename) const
+{
+ CacheType::const_iterator it = cache->find(filename);
+ if (it == cache->end())
+ return 0;
+
+ return it->second->raw_width();
+}
+
+
+unsigned int GCache::raw_height(string const & filename) const
+{
+ CacheType::const_iterator it = cache->find(filename);
+ if (it == cache->end())
+ return 0;
+
+ return it->second->raw_height();
+}
+
} // namespace grfx
+
/// How far have we got in loading the image?
ImageStatus status(InsetGraphics const &) const;
+ // Used to ascertain the Bounding Box of non (e)ps files.
+ unsigned int raw_width(string const & filename) const;
+ ///
+ unsigned int raw_height(string const & filename) const;
+
private:
/** Make the c-tor private so we can control how many objects
* are instantiated.
}
+unsigned int GCacheItem::raw_width() const
+{
+ if (!image_.get())
+ return 0;
+
+ return image_->getWidth();
+}
+
+
+unsigned int GCacheItem::raw_height() const
+{
+ if (!image_.get())
+ return 0;
+
+ return image_->getHeight();
+}
+
+
namespace {
string const findTargetFormat(string const & from)
*/
void changeDisplay(bool changed_background);
+ /// Used to ascertain the Bounding Box of non (e)ps files.
+ unsigned int raw_width() const;
+ ///
+ unsigned int raw_height() const;
+
private:
/** Start the image conversion process, checking first that it is
* necessary. If it is necessary, then a conversion task is started.