2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetGraphicsParams.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-07-31 12:30:10 +00:00
|
|
|
|
*
|
2002-01-29 09:26:24 +00:00
|
|
|
|
* \author Baruch Even
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2002-01-29 09:26:24 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
#include <config.h>
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetGraphicsParams.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyX.h" // for use_gui
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
2007-09-05 17:50:07 +00:00
|
|
|
|
#include "Buffer.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
|
#include "graphics/GraphicsParams.h"
|
2007-10-25 20:36:17 +00:00
|
|
|
|
#include "graphics/GraphicsTypes.h"
|
2002-06-28 11:22:56 +00:00
|
|
|
|
|
2005-01-27 21:05:44 +00:00
|
|
|
|
#include "support/convert.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
|
#include "support/debug.h"
|
2000-07-31 12:30:10 +00:00
|
|
|
|
#include "support/filetools.h"
|
2001-07-28 12:24:16 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
2002-05-28 11:50:04 +00:00
|
|
|
|
#include "support/lstrings.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
|
#include "support/Translator.h"
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
2007-11-28 22:12:03 +00:00
|
|
|
|
#include <ostream>
|
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
|
using namespace lyx::support;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
|
InsetGraphicsParams::InsetGraphicsParams()
|
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
|
init();
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
|
InsetGraphicsParams::InsetGraphicsParams(InsetGraphicsParams const & igp)
|
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
|
// I decided to skip the initialization since the copy will overwrite
|
|
|
|
|
// everything anyway.
|
|
|
|
|
// init();
|
|
|
|
|
copy(igp);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2007-11-28 22:12:03 +00:00
|
|
|
|
void InsetGraphicsParams::operator=(InsetGraphicsParams const & params)
|
2000-07-31 12:30:10 +00:00
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
|
// Are we assigning the object into itself?
|
|
|
|
|
if (this == ¶ms)
|
2007-11-28 22:12:03 +00:00
|
|
|
|
return;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
copy(params);
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
|
void InsetGraphicsParams::init()
|
|
|
|
|
{
|
2002-09-12 08:44:23 +00:00
|
|
|
|
filename.erase();
|
2002-08-24 22:02:30 +00:00
|
|
|
|
lyxscale = 100; // lyx scaling in percentage
|
2006-10-21 00:16:43 +00:00
|
|
|
|
display = graphics::DefaultDisplay; // display mode; see preferences
|
2007-03-02 22:20:32 +00:00
|
|
|
|
scale = string("100"); // output scaling in percentage
|
2007-04-28 12:58:49 +00:00
|
|
|
|
width = Length();
|
|
|
|
|
height = Length();
|
2002-09-12 08:44:23 +00:00
|
|
|
|
keepAspectRatio = false; // for LaTeX output
|
2002-08-24 22:02:30 +00:00
|
|
|
|
draft = false; // draft mode
|
|
|
|
|
noUnzip = false; // unzip files
|
2007-06-25 13:49:51 +00:00
|
|
|
|
scaleBeforeRotation = false; // scale image before rotating
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
bb = string(); // bounding box
|
|
|
|
|
clip = false; // clip image
|
|
|
|
|
|
2004-12-28 11:23:05 +00:00
|
|
|
|
rotateAngle = "0"; // angle of rotation in degrees
|
2002-09-12 08:44:23 +00:00
|
|
|
|
rotateOrigin.erase(); // Origin of rotation
|
2002-08-24 22:02:30 +00:00
|
|
|
|
subcaption = false; // subfigure
|
2002-09-12 08:44:23 +00:00
|
|
|
|
subcaptionText.erase(); // subfigure caption
|
|
|
|
|
special.erase(); // additional userdefined stuff
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
|
void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
|
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
|
filename = igp.filename;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
lyxscale = igp.lyxscale;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
display = igp.display;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
scale = igp.scale;
|
2002-01-29 09:26:24 +00:00
|
|
|
|
width = igp.width;
|
|
|
|
|
height = igp.height;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
keepAspectRatio = igp.keepAspectRatio;
|
|
|
|
|
draft = igp.draft;
|
|
|
|
|
noUnzip = igp.noUnzip;
|
2007-06-25 13:49:51 +00:00
|
|
|
|
scaleBeforeRotation = igp.scaleBeforeRotation;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
bb = igp.bb;
|
|
|
|
|
clip = igp.clip;
|
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
|
rotateAngle = igp.rotateAngle;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
rotateOrigin = igp.rotateOrigin;
|
|
|
|
|
subcaption = igp.subcaption;
|
|
|
|
|
subcaptionText = igp.subcaptionText;
|
2002-01-29 09:26:24 +00:00
|
|
|
|
special = igp.special;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
|
bool operator==(InsetGraphicsParams const & left,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
InsetGraphicsParams const & right)
|
2000-07-31 12:30:10 +00:00
|
|
|
|
{
|
2007-10-25 20:36:17 +00:00
|
|
|
|
return left.filename == right.filename &&
|
2002-08-24 22:02:30 +00:00
|
|
|
|
left.lyxscale == right.lyxscale &&
|
2002-05-01 10:23:51 +00:00
|
|
|
|
left.display == right.display &&
|
2002-08-24 22:02:30 +00:00
|
|
|
|
left.scale == right.scale &&
|
2002-05-01 10:23:51 +00:00
|
|
|
|
left.width == right.width &&
|
|
|
|
|
left.height == right.height &&
|
2002-08-24 22:02:30 +00:00
|
|
|
|
left.keepAspectRatio == right.keepAspectRatio &&
|
|
|
|
|
left.draft == right.draft &&
|
|
|
|
|
left.noUnzip == right.noUnzip &&
|
2007-06-25 13:49:51 +00:00
|
|
|
|
left.scaleBeforeRotation == right.scaleBeforeRotation &&
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
left.bb == right.bb &&
|
|
|
|
|
left.clip == right.clip &&
|
|
|
|
|
|
2004-12-28 11:23:05 +00:00
|
|
|
|
left.rotateAngle == right.rotateAngle &&
|
2002-05-01 10:23:51 +00:00
|
|
|
|
left.rotateOrigin == right.rotateOrigin &&
|
2002-08-24 22:02:30 +00:00
|
|
|
|
left.subcaption == right.subcaption &&
|
|
|
|
|
left.subcaptionText == right.subcaptionText &&
|
2007-10-25 20:36:17 +00:00
|
|
|
|
left.special == right.special;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2001-03-28 13:16:37 +00:00
|
|
|
|
bool operator!=(InsetGraphicsParams const & left,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
InsetGraphicsParams const & right)
|
2001-03-28 13:16:37 +00:00
|
|
|
|
{
|
2002-03-21 17:09:55 +00:00
|
|
|
|
return !(left == right);
|
2001-03-28 13:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
|
2007-09-05 17:50:07 +00:00
|
|
|
|
void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
|
2000-07-31 12:30:10 +00:00
|
|
|
|
{
|
2002-08-24 22:02:30 +00:00
|
|
|
|
// Do not write the default values
|
2002-03-25 11:04:34 +00:00
|
|
|
|
if (!filename.empty()) {
|
2007-09-15 18:31:32 +00:00
|
|
|
|
os << "\tfilename " << filename.outputFilename(buffer.filePath()) << '\n';
|
2008-01-10 23:39:58 +00:00
|
|
|
|
os << "\tembed " << (filename.embedded() ? filename.inzipName() : "\"\"") << '\n';
|
2000-08-14 09:44:53 +00:00
|
|
|
|
}
|
2002-08-24 22:02:30 +00:00
|
|
|
|
if (lyxscale != 100)
|
|
|
|
|
os << "\tlyxscale " << lyxscale << '\n';
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (display != graphics::DefaultDisplay)
|
|
|
|
|
os << "\tdisplay " << graphics::displayTranslator().find(display) << '\n';
|
2005-01-27 21:05:44 +00:00
|
|
|
|
if (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05)) {
|
|
|
|
|
if (!float_equal(convert<double>(scale), 100.0, 0.05))
|
2002-08-24 22:02:30 +00:00
|
|
|
|
os << "\tscale " << scale << '\n';
|
|
|
|
|
} else {
|
|
|
|
|
if (!width.zero())
|
|
|
|
|
os << "\twidth " << width.asString() << '\n';
|
2002-10-31 11:33:49 +00:00
|
|
|
|
if (!height.zero())
|
|
|
|
|
os << "\theight " << height.asString() << '\n';
|
2002-08-24 22:02:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keepAspectRatio)
|
|
|
|
|
os << "\tkeepAspectRatio\n";
|
|
|
|
|
if (draft) // draft mode
|
|
|
|
|
os << "\tdraft\n";
|
|
|
|
|
if (noUnzip)
|
|
|
|
|
os << "\tnoUnzip\n";
|
2007-06-25 13:49:51 +00:00
|
|
|
|
if (scaleBeforeRotation)
|
|
|
|
|
os << "\tscaleBeforeRotation\n";
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
2002-01-29 09:26:24 +00:00
|
|
|
|
if (!bb.empty()) // bounding box
|
|
|
|
|
os << "\tBoundingBox " << bb << '\n';
|
|
|
|
|
if (clip) // clip image
|
|
|
|
|
os << "\tclip\n";
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
2005-01-12 10:30:46 +00:00
|
|
|
|
if (!rotateAngle.empty()
|
2005-01-27 21:05:44 +00:00
|
|
|
|
&& !float_equal(convert<double>(rotateAngle), 0.0, 0.001))
|
2002-08-24 22:02:30 +00:00
|
|
|
|
os << "\trotateAngle " << rotateAngle << '\n';
|
2002-09-12 08:44:23 +00:00
|
|
|
|
if (!rotateOrigin.empty())
|
2002-08-24 22:02:30 +00:00
|
|
|
|
os << "\trotateOrigin " << rotateOrigin << '\n';
|
2000-08-14 09:44:53 +00:00
|
|
|
|
if (subcaption)
|
2002-05-01 10:23:51 +00:00
|
|
|
|
os << "\tsubcaption\n";
|
2002-01-29 09:26:24 +00:00
|
|
|
|
if (!subcaptionText.empty())
|
2002-05-01 10:23:51 +00:00
|
|
|
|
os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n';
|
2002-01-29 09:26:24 +00:00
|
|
|
|
if (!special.empty())
|
|
|
|
|
os << "\tspecial " << special << '\n';
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
2000-08-14 09:44:53 +00:00
|
|
|
|
|
2000-11-15 03:22:08 +00:00
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const & bufpath)
|
2000-07-31 12:30:10 +00:00
|
|
|
|
{
|
2000-08-14 09:44:53 +00:00
|
|
|
|
if (token == "filename") {
|
2002-05-29 22:07:59 +00:00
|
|
|
|
lex.eatLine();
|
2003-07-22 20:42:40 +00:00
|
|
|
|
filename.set(lex.getString(), bufpath);
|
2007-09-15 18:31:32 +00:00
|
|
|
|
} else if (token == "inzipName") {
|
2008-01-05 04:43:13 +00:00
|
|
|
|
// this option is currently ignored because only files in
|
|
|
|
|
// or under current document path is embeddable, and their
|
|
|
|
|
// inzipName is automatically determined.
|
2007-09-15 18:31:32 +00:00
|
|
|
|
lex.eatLine();
|
|
|
|
|
} else if (token == "embed") {
|
|
|
|
|
lex.next();
|
2008-01-10 23:39:58 +00:00
|
|
|
|
string const name = lex.getString();
|
|
|
|
|
filename.setInzipName(name);
|
|
|
|
|
filename.setEmbed(!name.empty());
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "lyxscale") {
|
|
|
|
|
lex.next();
|
|
|
|
|
lyxscale = lex.getInteger();
|
2000-08-14 09:44:53 +00:00
|
|
|
|
} else if (token == "display") {
|
|
|
|
|
lex.next();
|
2002-03-26 12:17:04 +00:00
|
|
|
|
string const type = lex.getString();
|
2006-10-21 00:16:43 +00:00
|
|
|
|
display = graphics::displayTranslator().find(type);
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "scale") {
|
2002-07-23 12:20:21 +00:00
|
|
|
|
lex.next();
|
2004-12-28 11:23:05 +00:00
|
|
|
|
scale = lex.getString();
|
2000-08-14 09:44:53 +00:00
|
|
|
|
} else if (token == "width") {
|
|
|
|
|
lex.next();
|
2007-04-28 12:58:49 +00:00
|
|
|
|
width = Length(lex.getString());
|
2004-12-28 11:23:05 +00:00
|
|
|
|
scale = string();
|
2000-08-14 09:44:53 +00:00
|
|
|
|
} else if (token == "height") {
|
|
|
|
|
lex.next();
|
2007-04-28 12:58:49 +00:00
|
|
|
|
height = Length(lex.getString());
|
2004-12-28 11:23:05 +00:00
|
|
|
|
scale = string();
|
2002-01-29 09:26:24 +00:00
|
|
|
|
} else if (token == "keepAspectRatio") {
|
|
|
|
|
keepAspectRatio = true;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "draft") {
|
|
|
|
|
draft = true;
|
|
|
|
|
} else if (token == "noUnzip") {
|
|
|
|
|
noUnzip = true;
|
2007-06-25 13:49:51 +00:00
|
|
|
|
} else if (token == "scaleBeforeRotation") {
|
|
|
|
|
scaleBeforeRotation = true;
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "BoundingBox") {
|
2002-10-31 11:33:49 +00:00
|
|
|
|
bb.erase();
|
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
|
if (i != 0)
|
2002-11-27 10:30:28 +00:00
|
|
|
|
bb += ' ';
|
2002-08-24 22:02:30 +00:00
|
|
|
|
lex.next();
|
2002-10-31 11:33:49 +00:00
|
|
|
|
bb += lex.getString();
|
2002-08-24 22:02:30 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (token == "clip") {
|
|
|
|
|
clip = true;
|
2000-08-14 09:44:53 +00:00
|
|
|
|
} else if (token == "rotateAngle") {
|
|
|
|
|
lex.next();
|
2004-12-28 11:23:05 +00:00
|
|
|
|
rotateAngle = lex.getString();
|
2002-01-29 09:26:24 +00:00
|
|
|
|
} else if (token == "rotateOrigin") {
|
|
|
|
|
lex.next();
|
|
|
|
|
rotateOrigin=lex.getString();
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "subcaption") {
|
|
|
|
|
subcaption = true;
|
|
|
|
|
} else if (token == "subcaptionText") {
|
2003-03-28 03:54:39 +00:00
|
|
|
|
lex.eatLine();
|
|
|
|
|
string sub = lex.getString();
|
|
|
|
|
// strip surrounding " "
|
|
|
|
|
subcaptionText = sub.substr(1, sub.length() - 2);
|
2002-04-08 14:47:21 +00:00
|
|
|
|
} else if (token == "special") {
|
|
|
|
|
lex.eatLine();
|
|
|
|
|
special = lex.getString();
|
2002-08-24 22:02:30 +00:00
|
|
|
|
|
|
|
|
|
// catch and ignore following two old-format tokens and their arguments.
|
2002-10-24 11:53:46 +00:00
|
|
|
|
// e.g. "size_kind scale" clashes with the setting of the
|
|
|
|
|
// "scale <value>" keyword.
|
2002-08-24 22:02:30 +00:00
|
|
|
|
} else if (token == "size_kind" || token == "lyxsize_kind") {
|
|
|
|
|
lex.next();
|
|
|
|
|
lex.getString();
|
2002-10-24 11:53:46 +00:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// If it's none of the above, it's not ours.
|
2000-08-14 09:44:53 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2000-07-31 12:30:10 +00:00
|
|
|
|
}
|
2002-05-28 11:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
graphics::Params InsetGraphicsParams::as_grfxParams() const
|
2002-05-28 11:50:04 +00:00
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
graphics::Params pars;
|
2008-01-07 03:34:21 +00:00
|
|
|
|
pars.filename = filename.availableFile();
|
2008-01-08 16:22:05 +00:00
|
|
|
|
pars.icon = filename.embedded() ? "pin.png" : "";
|
2002-08-24 22:02:30 +00:00
|
|
|
|
pars.scale = lyxscale;
|
2005-01-27 21:05:44 +00:00
|
|
|
|
pars.angle = convert<double>(rotateAngle);
|
2002-05-28 11:50:04 +00:00
|
|
|
|
|
|
|
|
|
if (clip) {
|
|
|
|
|
pars.bb = bb;
|
|
|
|
|
|
|
|
|
|
// Get the original Bounding Box from the file
|
2006-11-26 21:30:39 +00:00
|
|
|
|
string const tmp = readBB_from_PSFile(filename);
|
2007-11-15 20:04:51 +00:00
|
|
|
|
LYXERR(Debug::GRAPHICS, "BB_from_File: " << tmp);
|
2002-05-28 11:50:04 +00:00
|
|
|
|
if (!tmp.empty()) {
|
2007-08-10 11:47:12 +00:00
|
|
|
|
// FIXME: why not convert to unsigned int? (Lgb)
|
2005-01-27 21:05:44 +00:00
|
|
|
|
unsigned int const bb_orig_xl = convert<int>(token(tmp, ' ', 0));
|
|
|
|
|
unsigned int const bb_orig_yb = convert<int>(token(tmp, ' ', 1));
|
2002-05-28 11:50:04 +00:00
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
|
// new pars.bb values must be >= zero
|
2007-08-30 18:03:17 +00:00
|
|
|
|
if (pars.bb.xl > bb_orig_xl)
|
2002-08-24 22:02:30 +00:00
|
|
|
|
pars.bb.xl -= bb_orig_xl;
|
|
|
|
|
else
|
|
|
|
|
pars.bb.xl = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
|
if (pars.bb.xr > bb_orig_xl)
|
|
|
|
|
pars.bb.xr -= bb_orig_xl;
|
|
|
|
|
else
|
|
|
|
|
pars.bb.xr = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
|
if (pars.bb.yb > bb_orig_yb)
|
|
|
|
|
pars.bb.yb -= bb_orig_yb;
|
|
|
|
|
else
|
|
|
|
|
pars.bb.yb = 0;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
|
if (pars.bb.yt > bb_orig_yb)
|
|
|
|
|
pars.bb.yt -= bb_orig_yb;
|
|
|
|
|
else
|
|
|
|
|
pars.bb.yt = 0;
|
2002-05-28 11:50:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Paranoia check.
|
|
|
|
|
int const width = pars.bb.xr - pars.bb.xl;
|
|
|
|
|
int const height = pars.bb.yt - pars.bb.yb;
|
|
|
|
|
|
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
|
pars.bb.xl = 0;
|
|
|
|
|
pars.bb.xr = 0;
|
|
|
|
|
pars.bb.yb = 0;
|
|
|
|
|
pars.bb.yt = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (display == graphics::DefaultDisplay) {
|
2007-10-25 20:36:17 +00:00
|
|
|
|
pars.display = graphics::DisplayType(lyxrc.display_graphics);
|
2002-08-27 20:30:20 +00:00
|
|
|
|
} else {
|
|
|
|
|
pars.display = display;
|
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
2002-05-28 11:50:04 +00:00
|
|
|
|
// Override the above if we're not using a gui
|
2007-10-25 20:36:17 +00:00
|
|
|
|
if (!use_gui)
|
2006-10-21 00:16:43 +00:00
|
|
|
|
pars.display = graphics::NoDisplay;
|
2002-07-22 12:36:41 +00:00
|
|
|
|
|
2002-05-28 11:50:04 +00:00
|
|
|
|
return pars;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|