commit 8f3fdafd9e4e86c1d99b18648ba25da755158955
Author: Juergen Spitzmueller <[email protected]>
Date: Fri Dec 31 14:32:13 2021 +0100
GuiGraphics: check more carefully whether we have a changed BB
---
src/frontends/qt/GuiGraphics.cpp | 40 ++++++++++++++++++++++++++++++++++++-
src/frontends/qt/GuiGraphics.h | 2 +
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp
index aefe3d0..fd4e8f5 100644
--- a/src/frontends/qt/GuiGraphics.cpp
+++ b/src/frontends/qt/GuiGraphics.cpp
@@ -336,8 +336,8 @@ void GuiGraphics::on_newGroupPB_clicked()
void GuiGraphics::changeBB()
{
- bbChanged = true;
- LYXERR(Debug::GRAPHICS, "[bb_Changed set to true]");
+ bbChanged = isChangedBB();
+ LYXERR(Debug::GRAPHICS, "[bb_Changed set to " << bbChanged << "]");
changed();
}
@@ -347,6 +347,10 @@ void GuiGraphics::on_browsePB_clicked()
QString const str = browse(filename->text());
if (!str.isEmpty()) {
filename->setText(str);
+ // read in the bb values of the new file
+ // if there was no explicit custom viewport
+ if (!bbChanged)
+ getBB();
changed();
}
}
@@ -355,6 +359,7 @@ void GuiGraphics::on_browsePB_clicked()
void GuiGraphics::on_getPB_clicked()
{
getBB();
+ bbChanged = false;
}
@@ -741,6 +746,37 @@ void GuiGraphics::getBB()
}
+bool GuiGraphics::isChangedBB()
+{
+ string const fn = fromqstr(filename->text());
+ if (fn.empty())
+ return false;
+
+ string const bb = readBoundingBox(fn);
+ if (bb.empty())
+ return false;
+
+ // Compare orig bb values with the set ones
+ if (Length(token(bb, ' ', 0) + "bp") !=
+ Length(widgetToDoubleStr(lbX) +
fromqstr(lbXunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 1) + "bp") !=
+ Length(widgetToDoubleStr(lbY) +
fromqstr(lbYunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 2) + "bp") !=
+ Length(widgetToDoubleStr(rtX) +
fromqstr(rtXunit->currentText())))
+ return true;
+
+ if (Length(token(bb, ' ', 3) + "bp") !=
+ Length(widgetToDoubleStr(rtY) +
fromqstr(rtYunit->currentText())))
+ return true;
+
+ return false;
+}
+
+
bool GuiGraphics::isValid()
{
return !filename->text().isEmpty();
diff --git a/src/frontends/qt/GuiGraphics.h b/src/frontends/qt/GuiGraphics.h
index 66f614f..2687c08 100644
--- a/src/frontends/qt/GuiGraphics.h
+++ b/src/frontends/qt/GuiGraphics.h
@@ -68,6 +68,8 @@ private:
/// get bounding box from file
void getBB();
+ /// does the bounding box differ from the file?
+ bool isChangedBB();
/// Browse for a file
QString browse(QString const &) const;
/// Read the Bounding Box from a eps or ps-file
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs