X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FExternalTransforms.cpp;h=76578b2ea0814edc6fbc25ef6459fa213483c7c7;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=bad7b38d6b4236c5193890a82ca68ecef3cefd24;hpb=b89cc942eb458284f40f4d4e7db58890c3288979;p=lyx.git diff --git a/src/insets/ExternalTransforms.cpp b/src/insets/ExternalTransforms.cpp index bad7b38d6b..76578b2ea0 100644 --- a/src/insets/ExternalTransforms.cpp +++ b/src/insets/ExternalTransforms.cpp @@ -12,16 +12,14 @@ #include "ExternalTransforms.h" +#include "support/convert.h" #include "support/debug.h" - #include "support/lstrings.h" #include "support/lyxlib.h" // float_equal -#include "support/convert.h" #include "support/Translator.h" -#include - -#include // std::abs +#include // abs +#include #include using namespace std; @@ -33,7 +31,7 @@ namespace external { string const ExtraData::get(string const & id) const { - std::map::const_iterator it = data_.find(id); + map::const_iterator it = data_.find(id); return it == data_.end() ? string() : it->second; } @@ -58,7 +56,7 @@ bool ResizeData::usingScale() const bool RotationData::no_rotation() const { - return (angle.empty() || std::abs(convert(angle)) < 0.1); + return (angle.empty() || abs(convert(angle)) < 0.1); } @@ -66,7 +64,7 @@ string const RotationData::adjAngle() const { // Ensure that angle lies in the range -360 < angle < 360 double rotAngle = convert(angle); - if (std::abs(rotAngle) > 360.0) { + if (abs(rotAngle) > 360.0) { rotAngle -= 360.0 * floor(rotAngle / 360.0); return convert(rotAngle); } @@ -79,7 +77,7 @@ namespace { typedef Translator OriginTranslator; OriginTranslator const & originTranslator(); -} // namespace anon +} // namespace void RotationData::origin(string const & o) @@ -99,7 +97,7 @@ string const ResizeLatexCommand::front_impl() const if (data.no_resize()) return string(); - std::ostringstream os; + ostringstream os; if (data.usingScale()) { double const scl = convert(data.scale) / 100.0; os << "\\scalebox{" << scl << "}[" << scl << "]{"; @@ -137,7 +135,7 @@ string const ResizeLatexCommand::back_impl() const namespace { -std::ostream & operator<<(std::ostream & os, RotationData::OriginType type) +ostream & operator<<(ostream & os, RotationData::OriginType type) { switch (type) { case RotationData::DEFAULT: @@ -184,7 +182,7 @@ std::ostream & operator<<(std::ostream & os, RotationData::OriginType type) return os; } -} // namespace anon +} // namespace string const RotationLatexCommand::front_impl() const @@ -192,7 +190,7 @@ string const RotationLatexCommand::front_impl() const if (data.no_rotation()) return string(); - std::ostringstream os; + ostringstream os; os << "\\rotatebox"; if (data.origin() != RotationData::DEFAULT) @@ -217,9 +215,12 @@ string const ClipLatexOption::option_impl() const if (!data.clip || data.bbox.empty()) return string(); - std::ostringstream os; + ostringstream os; if (!data.bbox.empty()) - os << "bb=" << data.bbox << ','; + os << "bb=" << data.bbox.xl.asLatexString() << ' ' + << data.bbox.yb.asLatexString() << ' ' + << data.bbox.xr.asLatexString() << ' ' + << data.bbox.yt.asLatexString() << ','; if (data.clip) os << "clip,"; return os.str(); @@ -231,7 +232,7 @@ string const ResizeLatexOption::option_impl() const if (data.no_resize()) return string(); - std::ostringstream os; + ostringstream os; if (data.usingScale()) { double const scl = convert(data.scale); if (!float_equal(scl, 100.0, 0.05)) @@ -255,7 +256,7 @@ string const RotationLatexOption ::option_impl() const if (data.no_rotation()) return string(); - std::ostringstream os; + ostringstream os; os << "angle=" << data.angle << ','; if (data.origin() != RotationData::DEFAULT) @@ -280,11 +281,10 @@ string const sanitizeLatexOption(string const & input) // Strip any leading commas // "[,,,,foo..." -> "foo..." ("foo..." may be empty) string output; - boost::smatch what; - static boost::regex const front("^( *[[],*)(.*)$"); + smatch what; + static regex const front("^( *\\[,*)(.*)$"); - regex_match(it, end, what, front, boost::match_partial); - if (!what[0].matched) { + if (!regex_match(it, end, what, front)) { lyxerr << "Unable to sanitize LaTeX \"Option\": " << input << '\n'; return string(); @@ -294,10 +294,9 @@ string const sanitizeLatexOption(string const & input) // Replace any consecutive commas with a single one // "foo,,,,bar" -> "foo,bar" // with iterator now pointing to 'b' - static boost::regex const commas("([^,]*)(,,*)(.*)$"); + static regex const commas("([^,]*)(,,*)(.*)$"); for (; it != end;) { - regex_match(it, end, what, commas, boost::match_partial); - if (!what[0].matched) { + if (!regex_match(it, end, what, commas)) { output += string(it, end); break; } @@ -307,9 +306,8 @@ string const sanitizeLatexOption(string const & input) // Strip any trailing commas // "...foo,,,]" -> "...foo" ("...foo,,," may be empty) - static boost::regex const back("^(.*[^,])?,*[]] *$"); - regex_match(output, what, back); - if (!what[0].matched) { + static regex const back("^(.*[^,])?,*\\] *$"); + if (!regex_match(output, what, back)) { lyxerr << "Unable to sanitize LaTeX \"Option\": " << output << '\n'; return string(); @@ -317,7 +315,7 @@ string const sanitizeLatexOption(string const & input) output = what.str(1); // Remove any surrounding whitespace - output = support::trim(output); + output = trim(output); // If the thing is empty, leave it so, else wrap it in square brackets. return output.empty() ? output : "[" + output + "]"; @@ -327,18 +325,18 @@ string const sanitizeLatexOption(string const & input) namespace { template -void extractIt(boost::any const & any_factory, +void extractIt(any const & any_factory, Data const & data, Transformer & transformer) { if (any_factory.type() != typeid(Factory)) return; - Factory factory = boost::any_cast(any_factory); - if (!factory.empty()) + Factory factory = any_cast(any_factory); + if (factory) transformer = factory(data); } -} // namespace anon +} // namespace TransformCommand::ptr_type @@ -427,7 +425,7 @@ OriginTranslator const & originTranslator() return translator; } -} // namespace anon +} // namespace } // namespace external } // namespace lyx